AtCoder Beginner Contest 185 A~F

source tree clone error:fatal remote error: Repository not found 阅读详情


传送门: https://atcoder.jp/contests/abc185/tasks

A - ABC Preparation 签到

取 4 个 数 中 最 小 的 一 个 。 取4个数中最小的一个。 取4个数中最小的一个。

Code

#include <bits/stdc++.h>
using namespace std;

int main() {
	int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, min(b, min(c, d))) << endl;
}

B - Smartphone Addiction 模拟

暴 力 模 拟 , 只 要 中 中 途 中 电 量 < 0 , 直 接 输 出 N o 。 暴力模拟,只要中中途中电量<0,直接输出No。 暴力模拟,只要中中途中电量<0,直接输出No。
注 意 最 后 一 次 完 成 后 回 家 的 那 一 段 。 注意最后一次完成后回家的那一段。 注意最后一次完成后回家的那一段。

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pdd;

#define INF 0x3f3f3f3f
#define lowbit(x) x & (-x)
#define mem(a, b) memset(a , b , sizeof(a))
#define FOR(i, x, n) for(int i = x;i <= n; i++)

// const ll mod = 998244353;
// const ll mod = 1e9 + 7;
// const double eps = 1e-6;
// const double PI = acos(-1);
// const double R = 0.57721566490153286060651209;

struct Node {
    ll A, B;
}t[100005];

void solve() {
    ll n, m, T;
    cin >> n >> m >> T;
    for(int i = 1;i <= m; i++) cin >> t[i].A >> t[i].B;
    ll ans = n;
    for(int i = 1;i <= m; i++) {
        ans -= t[i].A - t[i - 1].B;
        if(ans <= 0) {
            cout << "No" << endl;
            return ;
        }
        ans = (ans + t[i].B - t[i].A > n ? n : ans + t[i].B - t[i].A);
    }
    if(ans > T - t[m].B) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
	solve();
}


C - Duodecim Ferra 排列组合

简 单 推 导 一 波 a n s = C n − 1 11 简单推导一波ans=C_{n-1}^{11} 简单推导一波ans=Cn−111​

注 意 会 爆 l o n g l o n g , 所 以 我 选 择 J a v a 大 数 。 注意会爆longlong,所以我选择Java大数。 注意会爆longlong,所以我选择Java大数。

Code

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	
	public static Scanner in = new Scanner(System.in);
	public static PrintStream out = new PrintStream(System.out);
	
	public static BigInteger ans = BigInteger.valueOf(1);
	public static int n;
	
	public static void solve() {
		n = in.nextInt();
		for(int i = n - 11;i <= n - 1; i++) {
			ans = ans.multiply(BigInteger.valueOf(i));
		}
		for(int i = 2;i <= 11; i++) {
			ans = ans.divide(BigInteger.valueOf(i));
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		solve();
	}

}

D - Stamp 思维

找 每 两 个 都 涂 了 颜 色 区 间 的 最 小 值 , 然 后 计 算 贡 献 。 找每两个都涂了颜色区间的最小值,然后计算贡献。 找每两个都涂了颜色区间的最小值,然后计算贡献。
注 意 m = 0 时 直 接 输 出 1 , 因 为 1 次 就 可 以 涂 完 。 注意m=0时直接输出1,因为1次就可以涂完。 注意m=0时直接输出1,因为1次就可以涂完。

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pdd;

#define INF 0x3f3f3f3f
#define lowbit(x) x & (-x)
#define mem(a, b) memset(a , b , sizeof(a))
#define FOR(i, x, n) for(int i = x;i <= n; i++)

// const ll mod = 998244353;
// const ll mod = 1e9 + 7;
// const double eps = 1e-6;
// const double PI = acos(-1);
// const double R = 0.57721566490153286060651209;

ll a[200005];

void solve() {
    int n, m; cin >> n >> m;
    for(int i = 1;i <= m; i++) cin >> a[i];
    sort(a + 1, a + m + 1);
    ll k = 0;
    a[0] = 0;
    for(int i = 1;i <= m; i++) {
        if((a[i] - a[i - 1] - 1) > 0) {
            if(k == 0) k = a[i] - a[i - 1] - 1;
            else k = min(k, a[i] - a[i - 1] - 1);
        }
    }
    if(k && n != a[m]) k = min(k, n - a[m]);
    ll ans = 0;
    if(k) {
        for(int i = 1;i <= m; i++) {
            if((a[i] - a[i - 1] - 1) > 0) {
                ans += (int) ceil(1.0 * (a[i] - a[i - 1] - 1) / k);
            }
        }

        if(n != a[m]) ans += (int)ceil(1.0 * (n - a[m]) / k);
    }

    if(m == 0) ans = 1;
    cout << ans << endl;
}

signed main() {
    solve();
}


E - Sequence Matching 线性dp

有 两 个 数 组 a 和 b , 长 度 分 别 为 n 和 m , 求 解 删 掉 x 个 数 后 , a 数 组 和 b 数 组 不 同 数 的 个 数 y , 输 出 x + y 。 有两个数组a和b,长度分别为n和m,求解删掉x个数后,a数组和b数组不同数的个数y,输出x+y。 有两个数组a和b,长度分别为n和m,求解删掉x个数后,a数组和b数组不同数的个数y,输出x+y。
考 虑 d p , d p [ i ] [ j ] 表 示 a 数 组 选 到 了 i 个 , b 数 组 选 到 了 第 j 个 的 x + y 答 案 。 考虑dp,dp[i][j]表示a数组选到了i个,b数组选到了第j个的x+y答案。 考虑dp,dp[i][j]表示a数组选到了i个,b数组选到了第j个的x+y答案。

所 以 我 们 有 以 下 四 种 状 态 转 移 : 所以我们有以下四种状态转移: 所以我们有以下四种状态转移:

  • 选 择 删 掉 a i , 保 留 b j , f [ i ] [ j ] = m i n ( f [ i ] [ j ] , f [ i − 1 ] [ j ] + 1 ) 选择删掉a_i,保留b_j,f[i][j] = min(f[i][j], f[i - 1][j] + 1) 选择删掉ai​,保留bj​,f[i][j]=min(f[i][j],f[i−1][j]+1)
  • 选 择 保 留 a i , 删 掉 b j , f [ i ] [ j ] = m i n ( f [ i ] [ j ] , f [ i ] [ j − 1 ] + 1 ) 选择保留a_i,删掉b_j,f[i][j] = min(f[i][j], f[i][j - 1] + 1) 选择保留ai​,删掉bj​,f[i][j]=min(f[i][j],f[i][j−1]+1)
  • 选 择 保 留 a i , 保 留 b j , f [ i ] [ j ] = m i n ( f [ i ] [ j ] , f [ i − 1 ] [ j − 1 ] ) 选择保留a_i,保留b_j,f[i][j] = min(f[i][j], f[i - 1][j - 1]) 选择保留ai​,保留bj​,f[i][j]=min(f[i][j],f[i−1][j−1])
  • 选 择 删 掉 a i , 保 留 b j , f [ i ] [ j ] = m i n ( f [ i ] [ j ] , f [ i − 1 ] [ j − 1 ] + 1 ) 选择删掉a_i,保留b_j,f[i][j] = min(f[i][j], f[i - 1][j - 1] + 1) 选择删掉ai​,保留bj​,f[i][j]=min(f[i][j],f[i−1][j−1]+1)

注 意 d p 数 组 的 初 始 化 。 注意dp数组的初始化。 注意dp数组的初始化。

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pdd;

#define lc u << 1
#define rc u << 1 | 1
#define mid (t[u].l + t[u].r) / 2
#define INF 0x3f3f3f3f
#define lowbit(x) x & (-x)
#define mem(a, b) memset(a , b , sizeof(a))
#define FOR(i, x, n) for(int i = x;i <= n; i++)

// const ll mod = 998244353;
// const ll mod = 1e9 + 7;
// const double eps = 1e-6;
// const double PI = acos(-1);
// const double R = 0.57721566490153286060651209;

const int N = 1005;
int f[N][N];

void solve() {
    int n, m; cin >> n >> m;
    vector<int> A(n + 1), B(m + 1);
    for(int i = 1;i <= n; i++) cin >> A[i];
    for(int i = 1;i <= m; i++) cin >> B[i];
    for(int i = 0;i <= n; i++)
        for(int j = 0;j <= m; j++)
            f[i][j] = INF;
    for(int i = 0;i <= n; i++) f[i][0] = i;
    for(int i = 0;i <= m; i++) f[0][i] = i;

    for(int i = 1;i <= n; i++) {
        for(int j = 1;j <= m; j++) {
            if(A[i] == B[j]) f[i][j] = min(f[i][j], f[i - 1][j - 1]);
            else f[i][j] = min(f[i][j], f[i - 1][j - 1] + 1);
            f[i][j] = min(f[i][j], f[i - 1][j] + 1);
            f[i][j] = min(f[i][j], f[i][j - 1] + 1);
        }
    }
    cout << f[n][m] << endl;
}

signed main() {
    solve();
}


F - Range Xor Query 线段树

一 道 单 点 修 改 , 维 护 区 间 异 或 和 的 裸 线 段 树 。 一道单点修改,维护区间异或和的裸线段树。 一道单点修改,维护区间异或和的裸线段树。

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pdd;

#define lc u << 1
#define rc u << 1 | 1
#define mid (t[u].l + t[u].r) / 2
#define INF 0x3f3f3f3f
#define lowbit(x) x & (-x)
#define mem(a, b) memset(a , b , sizeof(a))
#define FOR(i, x, n) for(int i = x;i <= n; i++)

// const ll mod = 998244353;
// const ll mod = 1e9 + 7;
// const double eps = 1e-6;
// const double PI = acos(-1);
// const double R = 0.57721566490153286060651209;

const int N = 3e5 + 10;

int A[N];

struct Node {
    int l, r;
    int sum;
}t[N << 2];

void push_up(int u) {
    t[u].sum = t[lc].sum ^ t[rc].sum;
}

void build(int u, int l, int r) {
    t[u].l = l; t[u].r = r;
    if(l == r) {
        t[u].sum = A[l];
        return ;
    }
    int m = (l + r) >> 1;
    build(lc, l, m);
    build(rc, m + 1, r);
    push_up(u);
}

void modify(int u, int p, int v) {
    if(t[u].l == t[u].r) {
        t[u].sum = t[u].sum ^ v;
        return ;
    }
    if(p <= mid) modify(lc, p, v);
    else modify(rc, p, v);
    push_up(u);
}

int query(int u, int ql, int qr) {
    if(ql <= t[u].l && t[u].r <= qr) {
        return t[u].sum;
    }
    int ans = 0;
    if(ql <= mid) ans ^= query(lc, ql, qr);
    if(qr > mid)  ans ^= query(rc, ql, qr);
    return ans;
}

void solve() {
    int n, q; cin >> n >> q;
    for(int i = 1;i <= n; i++) {
        cin >> A[i];
    }
    build(1, 1, n);
    while(q--) {
        int opt, x, y; cin >> opt >> x >> y;
        if(opt == 1) modify(1, x, y);
        else cout << query(1, x, y) << endl;
    }
}

signed main() {
    solve();
}


这一场非常友好,我很喜欢。

1.4 KFD 设备文件的获取与驱动握手协议 本文分析了OpenClose模块中libhsakmt与KFD内核驱动建立通信的过程。首先通过hsaKmtOpenKFD()函数打开/dev/kfd设备文件,建立用户态与内核态的通信通道。随后通过AMDKFD_IOC_GET_VERSION ioctl命令完成版本握手,确认双方的接口兼容性。KFD驱动采用Major.Minor二级版本号体系,当前主要版本为1,从1.1演进到1.19不断添加新功能。整个过程构成了用户态与内核态之间的"建连协议",是所有后续GPU操作的基础前提。 阅读详情

相关推荐

博图软件V15.1安装教程

博途软件安装

m0_46266496的博客 1万+

AtCoder题解 —— AtCoder Beginner Contest 185 —— B - Smartphone Addiction —— 模拟算法

题目相关 题目链接 AtCoder Regular Contest 185 B 题,https://atcoder.jp/contests/abc185/tasks/abc185_b。 Problem Statement The battery of Takahashi's smartphone has N mAh capacity. At time 0.5, 1.5, 2.5, and so on (that is, at time n+0.5 for every integer n), the

努力中的老周的专栏 735

quartusII简易CPU设计

优点可以实现八种运算,数据的存取及运算都能很好的实现,上板也很成功。缺点首先由于自己知识储备的缺乏,只能实现较为简单的8种运算,也是最简单的直接寻址。其次为了方便操作,没有从外部输入数据,都是直接使用存储在存储器中的数据。后续发展后续会在此简易CPU的基础上增加一些功能对CPU进行完善,如算术运算可以考虑是补码运算,输入、输出采用存储缓冲等等,直至完整的全功能的处理器。收获通过这次实践,更熟悉Quartus软件的操作。能过更加清楚每个器件的操作,比如计数器,运算器,译码器等的实现功能。

Kong08242022的博客 3487

AtCoder题解 —— AtCoder Beginner Contest 185 —— C - Duodecim Ferra —— 组合数学、背包

题目相关 题目链接 AtCoder Regular Contest 185 B 题, Problem Statement There is an iron bar of length L lying east-west. We will cut this bar at 11 positions to divide it into 12 bars. Here, each of the 12 resulting bars must have a positive integer length. Find

努力中的老周的专栏 996

帆软报表JS导出避坑指南:如何正确处理sessionid和参数传递

本文深入探讨了帆软报表中通过JavaScript实现一键导出的关键技术,重点解析了如何正确获取并传递sessionid以确保会话不丢失,以及如何构造包含必要参数的导出URL。文章详细对比了预览后导出与直接URL导出两种方式的差异,并提供了从参数拼接、前端触发下载到高级场景(如SPA集成)的完整避坑指南,帮助开发者构建稳定可靠的自定义导出功能。

weixin_42522857的博客 164

cefshap(C#)定义浏览器的右键菜单

菜单效果:复制(自带),搜索文本,打开链接,复制链接,刷新,检查,关于 public class MenuHandler : IContextMenuHandler { //public event Action<string> PopupRequest; void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrows

无线智能模块 可视DIY智能专家 1710

(Training 14)AtCoder Beginner Contest 185

A - ABC Preparation 输出四个中最小的即可 #include<iostream> #include<cstring> #include<algorithm> #include<unordered_map> using namespace std; typedef long long LL; unordered_map<LL,bool>mp; int main(){ int x,minv=1e9; for(int i=1;i&l

the_xin的博客 211

Linux 下安装 openjdk 17【详细步骤】

JDK17,安装教程。

甘蓝的专栏 7529

2021.5.9 第十二届蓝桥杯大赛软件赛省赛第二场大学B组(个人题解)

试题A:求余 直接输出答案即可 答案:1 #include <bits/stdc++.h> using namespace std; int main(){ int a=2021; printf("%d\n",a%20); return 0; } 试题B:双阶乘 思路: 因为只需后面五位,为了防止超过数据范围,可以直接每次乘完之后都对100000取模,因为超过五位的数字对答案无影响,可以直接舍去。 答案: 59375 #include<bits/stdc++.h&

m0_46335115的博客 1378

SonarQube 完整手册(2026 最新)

摘要: SonarQube是一款静态代码分析(SAST)平台,支持20+语言(如Java/Go/Python),提供Bug、漏洞、代码异味等检测,集成DevOps流水线。其架构包含服务端、扫描器和SonarLint插件。2026年四大版本:免费社区版(基础功能)、开发者版(多分支/PR分析)、企业版(合规治理)、数据中心版(高可用集群)。核心功能包括质量门禁(QualityGate)、密钥泄露检测及六大质量指标。部署推荐Docker+PostgreSQL,扫描支持Maven/CLI方式。

SmallBull的博客 689

9.16华为OD机试真题 新系统 - 矩阵螺旋遍历 (Java/Py/C/C++/Js/Go)

9.16华为OD机试真题 新系统 - 矩阵螺旋遍历 (Java/Py/C/C++/Js/Go)

算法大师! 685

AtCoder题解 —— AtCoder Beginner Contest 185 —— D - Stamp —— 模拟

题目相关 题目链接 AtCoder Regular Contest 185 D 题,https://atcoder.jp/contests/abc185/tasks/abc185_d。 Problem Statement There are N squares arranged in a row from left to right. Let Square i be the i-th square from the left. M of those squares, Square A1, A2, A

努力中的老周的专栏 826

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

AtCoder Beginner Contest 292

AtCoder Beginner Contest 292

青少年趣味编程 955

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

AtCoder Beginner Contest 186 A~F

AtCoder Beginner Contest 185 A~FA - Brick 签到B - Blocks on Grid 暴力C - Unlucky 7 暴力D - Sum of difference 思维E - Throne 扩展欧几里得F - Rook on Grid 扫描线 + BIT 传送门:https://atcoder.jp/contests/abc186/tasks A - Brick 签到 #include <bits/stdc++.h> using namespace

狙击美佐的博客 488

AtCoder Beginner Contest 185

AtCoder Beginner Contest 185

青少年趣味编程 993

AtCoder Beginner Contest 185 题解

A - ABC Preparation 排序找出最小值 int main() { ios_base::sync_with_stdio(false), cin.tie(0); vector<int> a(4); for (auto &i : a) cin >> i; sort(a.begin(), a.end()); cout...

橘嘉禾 143

AtCoder题解 —— AtCoder Beginner Contest 185 —— A - ABC Preparation

题目相关 题目链接 AtCoder Regular Contest 185 A题,https://atcoder.jp/contests/abc185/tasks/abc185_a。 Problem Statement Takahashi has decided to hold some number of programming contests. Holding one contest requires one 100-point problem, one 200-point problem,.

努力中的老周的专栏 618

AtCoder Beginner Contest 185E Sequence Matching | 字符串dp

题目链接:https://atcoder.jp/contests/abc185/tasks/abc185_e 题目大意: 给出两个字符串,你可以删除两个字符串中的任意一个字母 最终目的是使得两个字符串的长度相同 定义权值x = 删除字符的总数,y = 最终字符串下A[i] != B[i]的位置总数 询问x+y的最小值 题目思路: 经典字符串dp了 考虑dp[i][k]表示字符串A的前i个,字符串的前B个,组成相同长度的字符串的前提下,x+y的最小值 那么对于任意的位置(i,k) 即有:

一只酷酷光儿的博客 567

AtCoder Beginner Contest 185 F - Range Xor Query(线段树或树状数组)

链接: https://atcoder.jp/contests/abc185/tasks/abc185_f 题意: 给你n和m,n表示数组长度,m表示操作数量,然后给出数组,再给出m行操作,每行输入t,x,y。若t为1,则需将Ai的值改为Ai^y。t为2,则输出[l,r][l,r][l,r]区间的异或值。 思路:该题需要单点修改和区间查询,很明显可以使用线段树进行操作,我首先用的是线段树,但是后面看其他大佬的题解有更为简单的方式,也就是树状数组,因为树状数组可以进行单点修改,且异或值可以通过树状数组维护为一

m0_46335115的博客 406

AtCoder Regular Contest 185 A题

AtCoder Regular Contest 185 A题

XXUZZWZ的博客 599

AtCoder Beginner Contest 185 E - Sequence Matching

https://atcoder.jp/contests/abc185/tasks/abc185_e 我一开始还觉得推式子转化DP,搞了半天 然后最后发现直接dp[i][j]闭上眼睛就可以转移 然后又因为dp[i][0],[0][i]没初始化纠结半天 花了20多分钟,巨蠢无比 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxl=2010; int n,m,k,cnt,tot,c

binarycopycode 300

AtCoder Beginner Contest 112

前两个题很简单,这里就不整理了。 C - Pyramid 枚举+条件判断就行啦 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cmath&gt; #include&lt;algorithm&gt; using namespace std; const int maxn=110; struct{ int x,y,h...

405

浮点数二分查找模板题(数的三次方根)题解

本题是一个标准的浮点数二分查找模板题。 题目 题目链接 AcWing网站,https://www.acwing.com/problem/content/792/。 题目描述 给定一个浮点数n,求它的三次方根。 输入格式 共一行,包含一个浮点数n。 输出格式 共一行,包含一个浮点数,表示问题的解。 注意,结果保留6位小数。 样例输入 1000.00 样例输出 10.0...

努力中的老周的专栏 856

AtCoder Beginner Contest 167 B Easy Linear Programming 先选正数,再选零,最后选负数

AtCoder Beginner Contest 167 比赛人数11940 比赛开始后15分钟看到A题,之后每隔一分钟,看到一道题,在比赛开始后第21分钟看到所有题 AtCoder Beginner Contest 167 B Easy Linear Programming 先选正数,再选零,最后选负数 总目录详见https://blog.csdn.net/mrcrack/article/details/104454762 在线测评地址https://atcoder.jp/conte...

mrcrack的博客 412

Panasonic Programming Contest (AtCoder Beginner Contest 186) F.Rook on Grid

Panasonic Programming Contest (AtCoder Beginner Contest 186) F.Rook on Grid 题目链接

旺崽的博客 2754

AtCoder Beginner Contest 191 C - Digital Graffiti

思路:扫描所有’.'块,分4种情况计数。 c++代码: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int a[maxn]; int dx[] = {-1 , 1 , 0 , 0}; int dy[] = {0 , 0 , -1 , 1}; char g[20][20]; int h , w; int check(int r , int c , int t) { int cnt =

一只谜谜怪的博客 766
上一篇: Codeforces-235E-Number Challenge 莫比乌斯反演 + 记忆化gcd
下一篇: Codeforces Round #692 Div2 C题 并查集找环
狙击美佐
博客等级 码龄7年 147粉丝 166原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址