![](https://img-blog.csdnimg.cn/20190918140158853.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
Codeforces
文章平均质量分 63
Codeforces补题
吃饺子不蘸醋OxO
这个作者很懒,什么都没留下…
展开
-
AtCoder Beginner Contest 220
A - Find Multiple签到水题 找好边界关系就好代码#include <iostream> using namespace std; int a, b, c; void solve(){ scanf("%d%d%d", &a, &b, &c); int x1 = a / c, x2 = b / c; int y1 = a % c, y2 = b % c; if (x2 - x1 >= 1) printf("%d\n",原创 2021-10-09 10:30:14 · 137 阅读 · 0 评论 -
Codeforces Round #729 (Div. 2) (A - E)
A. Odd Set水题 看奇数个数是否为n代码#include <bits/stdc++.h>using namespace std;int n, sum;void solve(){ cin >> n; sum = 0; for (int i = 1; i <= n * 2; i ++ ) { int a; cin >> a; if (a & 1) sum ++ ; }原创 2021-11-11 21:29:51 · 241 阅读 · 0 评论 -
Codeforces Round #753 (Div. 3) (A - G)
A. Linear Keyboard暴力水题 用map来标记一下就行代码#include <bits/stdc++.h>using namespace std;const int N = 28;map<char, int> mp;void solve(){ string str; cin >> str; mp.clear(); for (int i = 0; i < 26; i ++ ) mp[str[i]] = i + 1; i原创 2021-11-06 15:41:19 · 126 阅读 · 0 评论 -
Codeforces Round #752 (Div. 2)
A. Era贪心水题 从第一个位置开始加1一直到所有数都满足 ai<=i 我们可以找到最大的 ai-i 遍历一下就能找到 在他的前面加 ai-i个1就可以满足题意了代码#include <bits/stdc++.h>using namespace std;typedef long long ll;ll a[110];ll amax;ll pos;void solve(){ int n; cin >> n; amax = -1; pos = -1原创 2021-11-01 14:29:49 · 78 阅读 · 0 评论 -
Codeforces Round #730 (Div. 2)
A. Exciting Bets思维题给定两个数a, b 通过进行若干个二者都加一或者减一操作来使得a和b的gcd最大我们可以知道 max_gcd肯定是 a+k, b+k 的 gcd 又a+k = t1 * max_gcd b + k = t2 * max_gcd所以我们可以得到 b - a = t3 * max_gcd 当t3取1时 max_gcd最大所以我们就得到了a, b操作后最大公因数 再去看加或减哪个操作数比较少即可代码#include <bits/stdc++.h>原创 2021-10-23 21:32:33 · 71 阅读 · 0 评论 -
Codeforces Round #737 (Div. 2)
A. Ezzat and Two Subsequences水题 把最大的那个拿出来 其他的求平均值即可 可以自己算一下 a1, a2, a3, a4 找最优解代码#include <bits/stdc++.h> using namespace std;typedef long long ll; const int N = 3e5 + 10; inline ll read(){ register ll x = 0, k = 1; char c = getchar();原创 2021-10-21 21:30:33 · 89 阅读 · 0 评论 -
Codeforces Round #749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1)
A - Windblume Ode题意 给定一个序列 从此序列中找出一个最大数量的子集 使得这个子集的总和为合数我们可以先计算原集合的和是合数吗 如果是则输出全部如果不是那么它必定是奇数 序列中肯定包含大于等于1个奇数 把它去掉即可代码#include <bits/stdc++.h>using namespace std;const int N = 410;inline int read(){ register int x = 0, k = 1; char c = g原创 2021-10-19 17:03:04 · 171 阅读 · 0 评论 -
Codeforces Round #745 (Div. 2) (A - C)
A. CQXYM Count Permutations观察所以全排列可以得到满足题意的排列反过来一定不满足题意 所以我们可以求2n的全排列除以2 这里要求逆元 费马小定理可以说一下有(a + b) % P = a % P + b % P true(a - b) % P = a % P - b % P true(a * b) % P = a % P * b % P true(a / b) % P = a % P / b % P false在求除数相余的时候要用逆元费马小定理 a^(p-1)原创 2021-10-17 17:27:02 · 177 阅读 · 0 评论 -
Codeforces Round #746 (Div. 2) (C 和 E)
C - Bakry and Partitioning给定一棵树 问是否可以通过割边是其变为成2到k个连通块 且所有连通块上的点异或起来相等我们可以这样考虑假如割之后的连通块个数为2x个 即偶数个 若这两个连通块的异或值相等 则整棵树的异或值应该为0那么假如割之后的联通块个数为2x+1个 即奇数个的时候该怎么办呢 这种情况整颗树的异或值肯定不为0的 且连通块个数肯定是大于三的 那么如果最后被割为五个连通块 我们可以使三个相邻连通块合并为一个连通块 异或值依然不变 所以我们只要可以在树中找出大于等于三个原创 2021-10-16 21:25:47 · 122 阅读 · 0 评论 -
Codeforces Round #743 (Div. 2)
A. Countdown水题 求每位的整数大小加1之和 再判断一下最右位是否为0即可代码#include <bits/stdc++.h>#define rep(i, n) for (int i = 1; i <= (n); i ++ )using namespace std;inline int read(){ register int x = 0, k = 1; char c = getchar(); while (c < '0' || c > '9原创 2021-10-15 21:31:01 · 94 阅读 · 0 评论 -
Codeforces Round #747 (Div. 2) (A - E1)
A. Consecutive Sum Riddle水题 找两个数l, r 使得l, r之间所有数之和为n 找 -(n - 1) 到 n就好代码#include <bits/stdc++.h>using namespace std;typedef long long ll;ll n, l, r;void solve(){ cin >> n; cout << 1 - n << ' ' << n << endl;原创 2021-10-15 21:16:43 · 1173 阅读 · 0 评论 -
Codeforces Round #748 (Div. 3) (D1 - E)
D1. All are Same同余题 求所有数加上k*x之后的值相等时k的最大值 即所有数同余k相等 我们可以找到最小值 所有数减去这个最小值然后求gcd所得值即为k的最大值为什么是减去最小值呢? 有 a ≡ b(mod k) 等价于 (a - b) % k = 0 所有我们必须使序列所有数减去一个序列之中的数字来求gcd 减去最小值是为了使得处理后的序列中不包含负数代码#include <bits/stdc++.h>#define rep(i, n) for (int i = 0原创 2021-10-15 19:55:16 · 101 阅读 · 0 评论 -
Codeforces Round #742 (Div. 2)
A. Domino Disaster签到水题代码#include <bits/stdc++.h> using namespace std; const int N = 110; int n;string st; void solve(){ cin >> n >> st; for (int i = 0; i < st.size(); i ++ ) if (st[i] == 'L') printf("L"); else if (st原创 2021-10-09 11:43:00 · 122 阅读 · 0 评论 -
Codeforces Global Round 16(A - E)
A. Median Maximization简单的贪心构造 题意让求中位数最大为多少 已知序列中所有数字均为非负 则我们可以让中位数之前的数全为0 然后中位数则可以最大取到总数除以剩下数向下取整代码#include <bits/stdc++.h> using namespace std; int n, s; void solve(){ cin >> n >> s; if (n % 2 == 1) { int m = n - n / 2;原创 2021-09-13 18:49:00 · 234 阅读 · 0 评论 -
Codeforces Round #741 (Div. 2)
有一说一这套题感觉有点差劲 打完之后感觉没有什么提高 全是结论题A. The Miracle and the Sleeper题意: 给出一个l, r区间从中要选择a和b 使得 a mod b 最大贪心 很容易的可以想到当l, r区间足够大的时候 b = a / 2 + 1 (a = r)的时候 a mod b取最大值 当l > r / 2 + 1的时候就b无法取到r / 2 + 1了 则直接r mod l 即可代码#include <bits/stdc++.h> #def原创 2021-08-27 20:11:51 · 164 阅读 · 0 评论 -
Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))
A. Simply Strange Sort看数据范围可以得出是一道简单的模拟题 但是坑还挺多的 很多人wa了几次只有在 对于i等于奇数时候不进行操作 且 对于i等于偶数时候也不进行操作时才能break(感觉像说了一句废话)刚开始我是只要某一次操作没进行交换就直接break 但是可能偶数操作完没进行交换 下次奇数操作又要进行交换 或者奇数操作完没进行交换 偶数交换完进行了交换代码#include <bits/stdc++.h> using namespace std; typ原创 2021-08-25 12:15:01 · 237 阅读 · 0 评论 -
Codeforces Round #735 (Div. 2)
传送门A. Cherry很好玩的一道思维题 给出n个数字的数组 求最大的对于[l, r]中 max(al, al + 1 ,… , ar) * min(al, al + 1, … , ar) 贪心来想可以得出遍历一遍求相邻两个元素乘积的最大值代码#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N = 1e5 + 10;ll n, a[N];void solve()原创 2021-08-24 16:52:02 · 103 阅读 · 0 评论 -
Integers Have Friends (cf - 1548B)
传送门题意给定n个点 求这些点的最长同余子串 且当m>1的时候 使得子串中所有数字mod m相等思路对于同余子串 我们可以通过差分相减得到新数组g[] 从而转换为求新数组中最长连续子序列 使得该序列中的gcd要>1 对于区间查询我们可以用线段树来维护 然后由于是连续子序列可以用双指针优化搜索区间代码#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N = 2e5 +原创 2021-08-22 23:18:56 · 197 阅读 · 0 评论 -
Codeforces Round #738
这场难度跨度好大 感觉前四题好简单 手速题 后两题一点思路都无A. Mocha and Math题意是对于可以任取的一个区间内 元素可以对偶进行&运算 即由两边到中间 两边可以进行与运算 而且可以操作无数次 对于任意两个元素的& 都会使得变小或不变 所以可以从头到尾依次取&代码#include <bits/stdc++.h> using namespace std; const int N = 40; int n, m; int main(){原创 2021-08-16 12:04:29 · 68 阅读 · 0 评论