合集-Codeforces
摘要:Codeforces Round 896 (Div. 2) A. Make It Zero 分析: 如果\(n\)为偶数,那么我们可以选定整个数组操作两次,所有元素必定会为0。 如果\(n\)为奇数,那么\(n-1\)必定为偶数,先将后\(n-1\)个数变为0,然后同理选定第一个数和第二个数操作两次
阅读全文
摘要:Codeforces Round 895 (Div. 3) A. Two Vessels 解题思路: \(d = \lceil {\frac {abs(a - b)} 2}\rceil\) \(ans = \lceil {\frac d c}\rceil\) 代码: #include <bits/s
阅读全文
摘要:Codeforces Round 897 (Div. 2) A. green_gold_dog, array and permutation 分析: 由题意: \[c_i = a_i - b_i \]\(c_i\)种类最多就是\(n\)个数都不同。 若\(a_i\)不断变大,\(b_i\)不断变小,
阅读全文
摘要:CodeTON Round 6 (Div. 1 + Div. 2, Rated, Prizes!) A. MEXanized Array 解题思路: 如果\(k > (x + 1) || k > n\)那么我们\(MEX\)都一定无法得到\(k\). 若\(k > (x + 1)\),则我们取不到\
阅读全文
摘要:Codeforces Round 898 (Div. 4) A. Short Sort 解题思路: 遍历所有交换情况,看是否有\(abc\). 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; const
阅读全文
摘要:Educational Codeforces Round 155 (Rated for Div. 2) A. Rigged! 解题思路: 若存在\(s[i] >= s[1]\)并且\(e[i] >= e[i]\),那么答案为\(-1\). 否则,答案为\(s[1]\). 代码: #include <
阅读全文
摘要:Codeforces Round 899 (Div. 2) A. Increasing Sequence 解题思路: 从左往右一个个看,从1开始,如果当前位相同\(+2\),否则\(+1\)。 代码: #include <bits/stdc++.h> using namespace std; usi
阅读全文
摘要:Codeforces Round 900 (Div. 3) A. How Much Does Daytona Cost? 解题思路: 可取一个元素作为子数组,数组中存在\(k\)即可。 代码: #include<bits/stdc++.h> using namespace std; using ll
阅读全文
摘要:Codeforces Round 627 (Div. 3) A. Yet Another Tetris Problem 解题思路: 最终所有位置减去的数是相同的,也就是说能否通过\(+2\)的方式使所有数相同。 即如果存在两个数之间的差为奇数,那么就不可能同时为\(0\)。 代码: #include
阅读全文
摘要:Codeforces Round 901 (Div. 2) A - Jellyfish and Undertale 解题思路: 卡在最后秒放。 若\(x_i > (a - 1)\):那么该\(x_i\)的贡献为\(a - 1\)。 否则,该\(x_i\)的贡献为\(x_i\)。 代码: #inclu
阅读全文
摘要:Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final A. Goals of Victory 解题思路: 答案为所有元素之和的负数。 代码: #include <bits/stdc++.h> using namespace std; u
阅读全文
摘要:Educational Codeforces Round 156 (Rated for Div. 2) A. Sum of Three 解题思路: 如果\(n \leq 6 或 n =9\),无解。 若\(n \% 3 == 0,t = \lfloor\frac{3}{n}\rfloor\): 若\
阅读全文
摘要:Codeforces Round 887 (Div. 2) A. Desorting 解题思路: 每次操作能使相邻数之差减\(2\),设最小相邻数之差为\(mind\),答案为\(ans = (mind + 1) / 2\)。 代码: #include <bits/stdc++.h> using n
阅读全文
摘要:Codeforces Round 905 (Div. 3) A. Morning 解题思路: 首先\(4\)个数字都要打印出来,所以\(ans\)起始值为\(4\)。 接着就是从左向右移动绝不回头,鼠标移动的距离和就是两两数字之差。 注意:这里\(0\)位置其实是\(10\). 代码: #inclu
阅读全文
摘要:Codeforces Round 906 (Div. 2) A. Doremy's Paint 3 解题思路: \(a_1 + a_2 = a_2 + a_3\),所以\(a_1 = a_3\)。以此类推。所以整个序列最多出现两种不同的数字。 \(n = 2\)时,必然存在。 \(n = 3\)时,
阅读全文
摘要:Codeforces Round 909 (Div. 3) A. Game with Integers 题意: 给定一个数\(x\),\(A,B\)两人轮流进行操作,\(A\)先操作。每次给\(x\)加一或者减一,操作完后\(x \% 3 == 0\)者获胜。判断获胜者。 解题思路: 判断\(A\)
阅读全文
摘要:Codeforces Round 910 (Div. 2) A. Milica and String 解题思路: 统计给定字符串\(s\)中的\(B\)的数量,记录为\(cnt\)。 如果\(cnt == k\):输出0; 如果\(cnt < k\):从左往右数,将第\(cnt - k\)个\(A\
阅读全文
摘要:Educational Codeforces Round 158 (Rated for Div. 2) A - Line Trip 解题思路: 每次到加油站油都会加满,所以我们考虑到达两个加油站间需要的最大油量即可。 注意:最后一站的油量是一个来回。 代码: #include <bits/stdc+
阅读全文
摘要:CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!) A - Jagged Swaps 解题思路: 若\(a[1] = 1\),则可以。 代码: #include <bits/stdc++.h> using namespace std; using ll
阅读全文
摘要:Codeforces Round 911 (Div. 2) A - Cover in Water 解题思路: 如果存在三个以上相邻的格子需要填,那么答案为二,否则有多少空格答案为多少。 代码: #include <bits/stdc++.h> using namespace std; using l
阅读全文
摘要:Codeforces Round 914 (Div. 2) A - Forked! 解题思路: 枚举皇后和国王能被骑士吃到的位置,重合的点数就是答案。 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; ty
阅读全文
摘要:Educational Codeforces Round 159 (Rated for Div. 2) A - Binary Imbalance 解题思路: 有一对\((0,1)\),那么\(0\)就能无限增长。 代码: #include <bits/stdc++.h> using namespac
阅读全文
摘要:Codeforces Round 919 (Div. 2) A. Satisfying Constraints 解题思路: 确定最大下界和最小上界。 然后看有多少个不可选数在界内。 代码: #include <bits/stdc++.h> using namespace std; using ll
阅读全文
摘要:Codeforces Round 920 (Div. 3) A - Square 解题思路: 取左下角和右上角。 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll,
阅读全文
摘要:Educational Codeforces Round 161 (Rated for Div. 2) A - Tricky Template 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; using
阅读全文
摘要:Codeforces Round 921 (Div. 2) 推荐题解 A - We Got Everything Covered! 解题思路: 以前\(k\)个字符都出现过至少一次为一轮,构造\(n\)轮即可。 代码: #include <bits/stdc++.h> using namespace
阅读全文
摘要:Codeforces Round 924 (Div. 2) A - Rectangle Cutting 解题思路: 初始矩形长宽为\((a,b)\),如果我们切\(a\),那么一定不能再拼接\(a\),否则一定一样。所以我们拼接\(b\),即将\(a\)对半分开得到两个\((\frac{a}{2},
阅读全文
摘要:Codeforces Round 925 (Div. 3) A - Recovering a Small String 解题思路: 枚举. 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; using pi
阅读全文
摘要:Codeforces Round 927 (Div. 3) A - Thorns and Coins 解题思路: 出现连续两个障碍之前,所有金币都能拿到。 代码: #include <bits/stdc++.h> using namespace std; using ll = long long;
阅读全文
摘要:Educational Codeforces Round 162 (Rated for Div. 2) A - Moving Chips 解题思路: 模拟一下,不难发现是\(1\)之间\(0\)的个数。 代码: #include <bits/stdc++.h> using namespace std
阅读全文
摘要:Codeforces Round 929 (Div. 3) A - Turtle Puzzle: Rearrange and Negate 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; using pi
阅读全文
摘要:Educational Codeforces Round 160 (Rated for Div. 2) A - Rating Increase 代码: #include <bits/stdc++.h> using namespace std; typedef long long ll; const
阅读全文
摘要:Codeforces Round 930 (Div. 2) A - Shuffle Party 解题思路: \(1\)会按着\(2\)的整数次幂往后跳。 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; u
阅读全文
摘要:Codeforces Round 931 (Div. 2) A - Too Min Too Max 解题思路: 最大、最小、次大、次小。 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; using pii
阅读全文
摘要:Codeforces Round 932 (Div. 2) A - Entertainment in MAC 解题思路: 如果翻转字符小于原字符,那么一直翻转即可。 否则,翻转\(n - 1\)次,然后添加一次。 代码: #include <bits/stdc++.h> using namespac
阅读全文
摘要:Codeforces Round 933 (Div. 3) A - Rudolf and the Ticket 解题思路: 暴力。 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; using pii =
阅读全文
摘要:Educational Codeforces Round 163 (Rated for Div. 2) A - Special Characters 解题思路: 一个相同的连续段会贡献两个特殊字符,所以答案一定是偶数,找个不同的数分隔开即可。 代码: #include <bits/stdc++.h>
阅读全文
摘要:Codeforces Round 934 (Div. 2) A - Destroying Bridges 解题思路: 完全图每个点的连边数为\(n - 1\)。 \(k < n - 1\):都可到达。 \(k \geq n - 1\):将点\(1\)的边删完,只能呆在点\(1\)。 代码: #inc
阅读全文
摘要:Codeforces Round 955 (Div. 2, with prizes from NEAR!) A. Soccer 解题思路: \(a\)区间为\([x_1, x_2]\),\(b\)区间为\([y_1, y_2]\)。二者不相交则不可能出现同分。 代码: #include <bits/
阅读全文
摘要:Educational Codeforces Round 167 (Rated for Div. 2) A. Catch the Coin 解题思路: 最终\(x\)一定会相等,我们考虑直接到下面接住他。 代码: #include <bits/stdc++.h> using namespace st
阅读全文
摘要:Codeforces Round 960 (Div. 2)(A - D) A - Submission Bait 解题思路: 假设直接选最大数,如果最大数有奇数个,\(Alice\)必胜,反之必败。 根据这个思路,从大到小看数字,找到第一个出现奇数次的数,从它开始选,就能保证每次\(Alice\)选
阅读全文
摘要:Pinely Round 4 (Div. 1 + Div. 2)(A - F) A - Maximize the Last Element 解题思路: 只有奇数位置能选。偶数位置前后都有奇数个数字,无法删完。 代码: #include <bits/stdc++.h> using namespace
阅读全文

浙公网安备 33010602011771号