Codeforces 题解
文章平均质量分 88
不定期更新一些Codeforces比赛的题解
Arctic_Clam
Hello World
展开
-
Codeforces Round #765 (Div. 2)A-D
Codeforces Round #765 (Div. 2)A. Ancient Civilization分析按位讨论, 对于第i位, 如果1多就选1, 0多就选0. 最后就可以把答案凑出来.代码#include <bits/stdc++.h>using namespace std;//#pragma GCC optimize(2)#define close(); ios::sync_with_stdio(false);#define endl '\n'#define re原创 2022-01-13 21:19:51 · 394 阅读 · 0 评论 -
Codeforces Round #757 (Div. 2)题解A-D2
Codeforces Round #757 (Div. 2)A. Divan and a Store分析:排序后从小到大贪心即可。代码:#include <bits/stdc++.h>using namespace std;//#pragma GCC optimize(2)#define close(); ios::sync_with_stdio(false);#define endl '\n'#define rep(i, l, r) for(int i = l; i &l原创 2021-11-27 23:44:15 · 544 阅读 · 0 评论 -
Codeforces Round #756 (Div. 3)题解A-F
Codeforces Round #756 (Div. 3)A. Make Even分析:三种情况本身是偶数, 答案为0十进制最高位是偶数, 答案为1十进制非最高位存在偶数, 答案为2代码:#include <bits/stdc++.h>using namespace std;//#pragma GCC optimize(2)#define close(); ios::sync_with_stdio(false);#define endl '\n'#define原创 2021-11-26 14:17:16 · 481 阅读 · 0 评论 -
Codeforces Global Round 17题解A-D
Codeforces Global Round 17A. Anti Light’s Cell Guessing分析:考虑0的情况就行了。代码:#include <bits/stdc++.h>using namespace std;//#pragma GCC optimize(2)#define close(); ios::sync_with_stdio(false);#define endl '\n'#define rep(i, l, r) for(int i = l; i原创 2021-11-24 14:40:58 · 944 阅读 · 4 评论 -
Educational Codeforces Round 115 (Rated for Div. 2)题解A-F
Educational Codeforces Round 115 (Rated for Div. 2)A. Computer Game分析:输出YES当且仅当,每一列都至少存在一个0.代码:#include <iostream>#include <algorithm>#include <queue>#include <cstring>#include <map>using namespace std;#define close原创 2021-10-11 21:42:47 · 717 阅读 · 0 评论 -
Codeforces Round #744 (Div. 3)题解A-G
Codeforces Round #744 (Div. 3)A. Casimir’s String Solitaire分析:不难发现,当且仅当B的个数等于A和C的个数的和时,可行。代码:#include <algorithm>#include <iostream>using namespace std;const int N = 500;char s[N];void solve(){ scanf("%s",s); int a, b; a = b原创 2021-09-29 15:45:24 · 442 阅读 · 0 评论 -
Codeforces Round #742 (Div. 2)题解A-E
Codeforces Round #742 (Div. 2)A. Domino Disaster描述:Alice有一个包含2行和n列的网格。她使用大小为1×2的n个多米诺骨牌完全覆盖网格(Alice可以垂直或水平放置它们),并且每个单元格应该由一个多米诺骨牌覆盖。现在,她决定向鲍勃展示一排网格。帮助Bob找出网格的另一行是什么样子分析:略。代码:#include <algorithm>#include <iostream>using namespace std;原创 2021-09-07 21:01:17 · 157 阅读 · 0 评论 -
Codeforces Round #741 (Div. 2)题解A-E
Codeforces Round #741 (Div. 2)传送门A. The Miracle and the Sleeper不难证明答案等于 r%(max(l,⌊r2⌋+1))r\%(\max(l, \lfloor\frac{r}{2}\rfloor+1))r%(max(l,⌊2r⌋+1))#include <algorithm>#include <iostream>using namespace std;void solve(){ int l, r原创 2021-09-02 21:25:43 · 150 阅读 · 0 评论 -
Harbour.Space Scholarship Contest 2021-2022 (open for everyone, rated, Div. 1 + Div. 2) 题解A-E
A. Digits Sum分析:显然以9结尾的十进制数都符合题目要求#include <iostream>#include <algorithm>using namespace std;int main(){ int t; cin >> t; while(t--) { int n; cin >> n; cout << (n/10) + ((n%10)/9) << en原创 2021-07-23 13:55:41 · 182 阅读 · 0 评论 -
Codeforces Round #727 (Div. 2)题解A-D
A. Contest Start分析:首先不难想到倒数第⌊t/x⌋\lfloor t/x\rfloor⌊t/x⌋个人开始, 每往后数一个人, 不满值会减一, 故可以得出:answer=n∗(n−1)2 ,n≤⌊t/x⌋answer = \frac{n*(n-1)}{2} \space \space ,n\le\lfloor t/x\rflooranswer=2n∗(n−1) ,n≤⌊t/x⌋考虑从倒数第⌊t/x⌋\lfloor t/x\rfloor⌊t/原创 2021-06-21 00:01:20 · 285 阅读 · 0 评论 -
Codeforces Round #726 (Div. 2)题解A-E1
A. Arithmetic Array分析:当sum大于n时,那么添加(sum-n)个0,当sum小于n时,只需要添加一个数即可。#include <iostream>using namespace std;int main(){ int t; cin >> t; while(t--) { int n; cin >> n; int sum = 0; for(int i = 0; i &l原创 2021-06-19 14:02:16 · 373 阅读 · 6 评论 -
Codeforces LATOKEN Round 1 (Div. 1 + Div. 2)题解A-D
A. Colour the Flag略#include <iostream>#include <algorithm>#include <string>using namespace std;char a[100][100]; int main(){ int t; cin >> t; while(t--) { int n, m; cin >> n >> m; stri原创 2021-06-14 09:22:54 · 261 阅读 · 0 评论 -
Codeforces Round #725 (Div. 3)题解A-G
A. Stone Game分析:考虑从两边删,还是从一遍删,选比较小的那个#include <iostream>#include <algorithm>using namespace std;int a[200];int main(){ int t; cin >> t; a[101] = 101; while(t--) { int n; cin >> n; int minx = 10原创 2021-06-11 09:26:46 · 342 阅读 · 0 评论 -
Codeforces Round #724 (Div. 2)题解A-D
A. Omkar and Bad Story分析:显然有负数存在不可能满足题意,故输出NO。如果只有非负数的话,那么直接输出以0开头,100结尾的,公差为1的等差数列即可。因为值域是[-100,100],而数组大小的限制是三百以内。代码:#include <iostream>#include <algorithm>using namespace std;int a[110];int main(){ int t; cin >> t; wh原创 2021-06-07 10:48:42 · 349 阅读 · 5 评论 -
Educational Codeforces Round 110 (Rated for Div. 2) 题解A-D
A. Fair Playoff分析:略#include <iostream>#include <algorithm>using namespace std;int a[10];int main(){ int t; cin >> t; while(t--) { for(int i = 0; i < 4; i++) cin >> a[i]; int x = max(a[0], a[1]),原创 2021-06-05 09:42:39 · 234 阅读 · 0 评论 -
Codeforces Round #723 (Div. 2) 题解A-C2
A. Mean Inequality分析:很简单的构造。代码:#include <iostream>#include <algorithm>#include <vector>using namespace std;const int N = 100;int a[N], b[N];int main(){ int t; cin >> t; while(t--) { int n; cin >>原创 2021-06-03 17:54:27 · 235 阅读 · 0 评论 -
Codeforces Round #722 (Div. 2)题解(A-D)
Codeforces Round #722 (Div. 2)题解A. Eshag Loves Big Arrays分析:最小的元素是不可能被消除的,其余比最小元素严格大的元素都可以和最小元素组成一对然后被消除。因此最后只会有最小元素留下来。#include <algorithm>#include <iostream>using namespace std;const int N = 3e5+100;int a[N]; int main(){ int t;原创 2021-05-25 13:41:03 · 142 阅读 · 0 评论 -
Codeforces Round #719 (Div. 3) 题解A-G
补题, 顺便写个题解。A. Do Not Be Distracted!分析:略。#include <iostream>#include <algorithm>#include <string>using namespace std;string s;int main(){ int t; cin >> t; while(t--) { int n; cin >> n >> s;原创 2021-06-09 21:49:18 · 116 阅读 · 0 评论 -
Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)
题目链接A. Prison Break显然对矩阵四个角分别对(r,w)(r,w)(r,w)求距离取最大值即可。代码实现#include <iostream>#include <stdlib.h>#include <algorithm>using namespace std;int main(){ int t; cin >> t; while(t--) { int n, m, r, c;cin >原创 2020-11-29 19:49:29 · 192 阅读 · 0 评论 -
Codeforces Round #680 div2 题解(A-D)
题目链接A. Array Rearrangment将给定的a,b数组从小到大排序,然后a的第i个匹配b的第n-i-1个,若a[i]+b[n-i-1]>x, 则不合法。#include <bits/stdc++.h>using namespace std;int a[100], b[100];int main(){ int t; cin >> t; while(t--) { int n, k; cin >> n >> k;原创 2020-11-02 19:22:24 · 197 阅读 · 0 评论