
周赛
文章平均质量分 76
Wiz1code(算法号)
这个作者很懒,什么都没留下…
展开
-
「Codeforces」 Round #779 (Div. 2)
A. Marin and Photoshoot题目大意对于给定的010101串,可以在其中添加若干个 111,使得任意区间内, 000 的个数不超过 111 的个数。解题思路对于本题,我们只关心前后距离不超过2的两个0:对于010, 不合法,需要在中间再加一个1对于100或001不合法,需要在两个0中加入两个1即: 每两个0之间,至少需要两个1Codevoid solve() { int n; string s; vector<int> v; cin &g原创 2022-03-28 12:07:28 · 909 阅读 · 0 评论 -
「Codeforces」 Edu Round #125 (Div. 2)
A. Integer Moves解题思路本题只存在三种情况:给出点为(0,0)本身,则只需要0步给出点与(0,0)的距离为整数,则只需要1步给出点与(0,0)的距离不为整数的情况下,只需要2步对于第3种情况: 第1步移到原点的水平或垂直方向,第2步移到原点Codevoid solve() { int x, y; cin >> x >> y; int s = sqrt(x * x + y * y); if (x == 0 &a原创 2022-03-23 20:37:11 · 619 阅读 · 0 评论 -
「Atcoder」abc243 A—E
A - ShampooCodesigned main(){ int v, a, b, c; cin >> v >> a >> b >> c; while (1) { if (v < a) {puts("F"); return 0;} v -= a; if (v < b) {puts("M"); return 0;}原创 2022-03-13 13:00:10 · 785 阅读 · 0 评论 -
「Codeforces」 Round #777 (Div. 2) A —D
A. Madoka and Math Dad解题思路根据样例发现总是“2121···”或“121212”为什么是这样呢?因为1和2是最小的两位数,通过这样的交替,我们可以使得分解出的位数更多通过模拟一些例子我们可以发现其实就是对%3做讨论:如果n % 3 == 0, 则输出(n / 3)个 “21” (比“12”更大)如果n % 3 == 1, 则输出(n / 3)个 “12” (拆解出的位数更多) + 末尾的一个"1"如果n % 3 == 2, 则输出(n / 3)个 “21” (比“12”原创 2022-03-12 11:52:35 · 942 阅读 · 2 评论 -
「Codeforces」 Educataion Round #124 (Div. 2) A—D
A. Playoff解题思路可以观察到在第一轮所有偶数就已经被淘汰了后面的所有轮的两个数相加都为偶数,所以输出较大的那个奇数而较大的那个奇数就是(1 << x) - 1Codevoid solve(){ int x; cin >> x; cout << ((1 << x) - 1) << endl; // 等价于2 ^ x - 1, 不过位运算更快些}B. Prove Him Wrong解题思路题目说,要原创 2022-03-11 12:03:42 · 1055 阅读 · 5 评论 -
「Atcoder」abc242 题解
A - T-shirtCodevoid solve(){ int a, b, c, x; cin >> a >> b >> c >> x; if(x <= a) printf("%.12lf\n", 1.0); else if(x <= b) { double res=c; res /= (b-a); printf("%.12lf\n",res);原创 2022-03-09 21:31:29 · 926 阅读 · 0 评论 -
「Codeforces」 Round #776 (Div. 3)
A. Deletions of Two Adjacent LettersCodevoid solve(){ string s; char c; cin >> s >> c; bool flag = false; for (int i = 0; i < s.length(); i++) if (s[i] == c && i % 2 == 0) { flag = t原创 2022-03-09 21:29:52 · 498 阅读 · 0 评论 -
「LeetCode」第73场双周赛 题解
6024. 数组中紧跟 key 之后出现最频繁的数字Codeclass Solution {public: int mostFrequent(vector<int>& nums, int key) { int n = nums.size(); int ans = 0; unordered_map<int, int> mp; for (int i = 0; i <= n - 2; i++) {原创 2022-03-06 22:37:42 · 680 阅读 · 0 评论