11 2023 档案
摘要:调和级数枚举倍数模型 参考博客: 算法学习笔记27:素数筛法【埃氏筛法、线性筛法】 OI&ACM]调和级数枚举倍数模型 板子(时间复杂度\(O(nlogn)\)): for(int i = 1;i<=n;i++) { for(int j = i;j<=n;j += i) { ??? } } 应用:
阅读全文
摘要: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\
阅读全文
摘要:牛客小白月赛81 A. 小辰打比赛 解题思路: 遍历找到小于\(x\)的数累加即可。 代码: #include<bits/stdc++.h> using namespace std; void solve() { int n,x; int ans = 0; cin >> n >> x; for(in
阅读全文
摘要:Codeforces Round 909 (Div. 3) A. Game with Integers 题意: 给定一个数\(x\),\(A,B\)两人轮流进行操作,\(A\)先操作。每次给\(x\)加一或者减一,操作完后\(x \% 3 == 0\)者获胜。判断获胜者。 解题思路: 判断\(A\)
阅读全文
摘要:基础练习1 HDU1214 圆桌会议 题意: 有一个\(1 \sim n\)的升序圆排列,我们每次能让相邻两个数交换位置,至少操作多少次,能使得每个数前后两个数都发生交换。 解题思路: 其实就是将一个\(1 \sim n\)的圆排列通过交换相邻元素得到\(n \sim 1\)的圆排列。 简单手玩一下
阅读全文
摘要:Toyota Programming Contest 2023#7(AtCoder Beginner Contest 328) A. Not Too Hard 题意: 将给定的数列\(a\)中数值小于\(x\)的数累加。 解题思路: 模拟。 代码: #include<bits/stdc++.h> u
阅读全文
摘要:HHKB Programming Contest 2023(AtCoder Beginner Contest 327) A. ab 解题思路: 模拟即可。 代码: #include <bits/stdc++.h> using namespace std; using ll = long long;
阅读全文
摘要: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\)时,
阅读全文