随笔分类 - Codeforces
摘要:Educational Codeforces Round 159 (Rated for Div. 2) A - Binary Imbalance 解题思路: 有一对\((0,1)\),那么\(0\)就能无限增长。 代码: #include <bits/stdc++.h> using namespac
阅读全文
摘要:Codeforces Round 914 (Div. 2) A - Forked! 解题思路: 枚举皇后和国王能被骑士吃到的位置,重合的点数就是答案。 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; ty
阅读全文
摘要:Codeforces Round 911 (Div. 2) A - Cover in Water 解题思路: 如果存在三个以上相邻的格子需要填,那么答案为二,否则有多少空格答案为多少。 代码: #include <bits/stdc++.h> using namespace std; using l
阅读全文
摘要:CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!) A - Jagged Swaps 解题思路: 若\(a[1] = 1\),则可以。 代码: #include <bits/stdc++.h> using namespace std; using ll
阅读全文
摘要:Educational Codeforces Round 158 (Rated for Div. 2) A - Line Trip 解题思路: 每次到加油站油都会加满,所以我们考虑到达两个加油站间需要的最大油量即可。 注意:最后一站的油量是一个来回。 代码: #include <bits/stdc+
阅读全文
摘要:Codeforces Round 910 (Div. 2) A. Milica and String 解题思路: 统计给定字符串\(s\)中的\(B\)的数量,记录为\(cnt\)。 如果\(cnt == k\):输出0; 如果\(cnt < k\):从左往右数,将第\(cnt - k\)个\(A\
阅读全文
摘要:Codeforces Round 909 (Div. 3) A. Game with Integers 题意: 给定一个数\(x\),\(A,B\)两人轮流进行操作,\(A\)先操作。每次给\(x\)加一或者减一,操作完后\(x \% 3 == 0\)者获胜。判断获胜者。 解题思路: 判断\(A\)
阅读全文
摘要: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 905 (Div. 3) A. Morning 解题思路: 首先\(4\)个数字都要打印出来,所以\(ans\)起始值为\(4\)。 接着就是从左向右移动绝不回头,鼠标移动的距离和就是两两数字之差。 注意:这里\(0\)位置其实是\(10\). 代码: #inclu
阅读全文
摘要:Codeforces Round 887 (Div. 2) A. Desorting 解题思路: 每次操作能使相邻数之差减\(2\),设最小相邻数之差为\(mind\),答案为\(ans = (mind + 1) / 2\)。 代码: #include <bits/stdc++.h> using n
阅读全文
摘要: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 902 (Div. 2, based on COMPFEST 15 - Final A. Goals of Victory 解题思路: 答案为所有元素之和的负数。 代码: #include <bits/stdc++.h> using namespace std; u
阅读全文
摘要:Codeforces Round 901 (Div. 2) A - Jellyfish and Undertale 解题思路: 卡在最后秒放。 若\(x_i > (a - 1)\):那么该\(x_i\)的贡献为\(a - 1\)。 否则,该\(x_i\)的贡献为\(x_i\)。 代码: #inclu
阅读全文
摘要:Codeforces Round 627 (Div. 3) A. Yet Another Tetris Problem 解题思路: 最终所有位置减去的数是相同的,也就是说能否通过\(+2\)的方式使所有数相同。 即如果存在两个数之间的差为奇数,那么就不可能同时为\(0\)。 代码: #include
阅读全文
摘要:Codeforces Round 900 (Div. 3) A. How Much Does Daytona Cost? 解题思路: 可取一个元素作为子数组,数组中存在\(k\)即可。 代码: #include<bits/stdc++.h> using namespace std; using ll
阅读全文
摘要:Codeforces Round 899 (Div. 2) A. Increasing Sequence 解题思路: 从左往右一个个看,从1开始,如果当前位相同\(+2\),否则\(+1\)。 代码: #include <bits/stdc++.h> using namespace std; usi
阅读全文
摘要:Educational Codeforces Round 155 (Rated for Div. 2) A. Rigged! 解题思路: 若存在\(s[i] >= s[1]\)并且\(e[i] >= e[i]\),那么答案为\(-1\). 否则,答案为\(s[1]\). 代码: #include <
阅读全文
摘要:Codeforces Round 898 (Div. 4) A. Short Sort 解题思路: 遍历所有交换情况,看是否有\(abc\). 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; const
阅读全文
摘要:CodeTON Round 6 (Div. 1 + Div. 2, Rated, Prizes!) A. MEXanized Array 解题思路: 如果\(k > (x + 1) || k > n\)那么我们\(MEX\)都一定无法得到\(k\). 若\(k > (x + 1)\),则我们取不到\
阅读全文
摘要: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
阅读全文