2025 4.7~4.13
本部蓝桥试炼 续上回 B 线段树板子,但奈何我现在没法手撕线段树哇(码太长了) 遂选择树状数组,但是–按理说树状数组(nlog2n)的复杂度是能过此题的,而且赛后题解里也说了树状数组能过,为什么才拿25分?? (后来发现问题了–忘记取模,唉) 题补就写线段树的吧 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879#include <bits/stdc++.h>#define int long longusing namespace std;const int N = 1e5+10;const int mod = 1e9+7; int a[N]; int tree[N<<2]; int tag[N<<2]; int ls(int p){return...
2025 3.31~4.6
牛客月赛113 A 签到 12345678910111213141516#include <bits/stdc++.h>using namespace std;int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int sum = 1; string s; cin >> s; for(char i : s){ if(i == '-') sum -= 1; else sum *= 2; } cout << (sum >= 2025 ? "YES\n" : "NO\n"); return 0;} B 统计相邻相同字符即可 12345678910111213141516#include <bits/stdc++.h>using namespace std;int...
2025 3.24~3.30
牛客周赛86 A 签到 1234567891011#include <bits/stdc++.h>using namespace std;int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int x,y; cin >> x >> y; cout << (y%x ? y/x+1 : y/x) << '\n'; return 0; } B 贪心,很明显删除全部负数就可以使总和最大,也就是把正数相加 1234567891011121314151617181920212223#include <bits/stdc++.h>#define int long longusing namespace std;const int maxn = 2e5+1;signed main(void){ ...
2025 3.17~3.23
牛客周赛 85 A 签到 1234567891011#include <bits/stdc++.h>using namespace std;int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int n; cin >> n; cout << (n%2 ? "kou\n" : "yukari\n"); return 0;} B 贪心 由题目可知,小红和小紫的拿取元素的倾向都是拿尽可能小的元素 因此直接对数组升序排序,然后遍历数组对x进行操作即可 12345678910111213141516171819202122#include <bits/stdc++.h>using namespace std;const int maxn = 1e5+1;int arr[maxn];int main(void){ ...
2025 3.10~3.16
牛客周赛84 续上周 D 赛时用的数学方法,花的时间和代码量比较多。差分我写得少,这里用题解的差分方法补个题 用差分数组对每个k区间做修改,然后求和以及相邻数字绝对值差对陡峭值的贡献即可 123456789101112131415161718192021222324#include <bits/stdc++.h> using namespace std;const int maxn = 1e6+1;int t[maxn],d[maxn];int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int n,k,ans=0; cin >> n >> k; string s; cin >> s; for(int i=1,j=k;j<=n;i++,j++){ d[i]++; d[j]--; } t[0]=0; for(int...
2025 3.3~3.9
牛客月赛 111 A 贪心,田鸡的最大的a比齐威王次大的v大,田鸡的次大的a比齐威王最小的v大就能赢 123456789101112131415161718#include <bits/stdc++.h>using namespace std;int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int v[3],a[3]; for(int i=0;i<3;i++) cin >> v[i]; for(int i=0;i<3;i++) cin >> a[i]; sort(v,v+3); sort(a,a+3); if(a[2] > v[1] && a[1] > v[0]) cout << "Yes\n"; else cout << "No\n"; ...
2025 2.24~3.2
牛客周赛81 A 题目 签到 代码 12345678910111213#include <bits/stdc++.h>using namespace std;int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int a,b,c; cin >> a >> b >> c; if(a==b && b==c) cout <<"Yes\n"; else if(a+1==b && b+1==c) cout << "Yes\n"; else cout << "NO\n"; return...
2025 2.10~2.16
牛客周赛80 A 题目 签到 代码 123456789101112#include <bits/stdc++.h>using namespace std;int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int x,y; cin >> x >> y; if(x >= y) cout << x-y << '\n'; else cout << "quit the competition!\n"; return 0;} B 题目 降序排序,相邻两项之间相减,取绝对值,求和即可 代码 123456789101112131415161718192021222324#include <bits/stdc++.h>using namespace std;const int maxn = 2e5+1;bool...
2025 2.3~2.9
牛客寒假训练营1 大家都报了训练营呐,那我也报一个 ^v^(虽晚不亏) 补一下之前的 A 题目 这题考察素数。由题目得,ai不超过1e9,因此如果给的数有1就输入-1(1和任何数都构成倍数关系),否则输出任意一个比1e9大的素数、 那比1e9大的素数怎么找呢? 新开一个cpp,用埃氏筛把这个数找到,是999999937,CV 代码 埃氏筛 1234567891011121314151617181920212223#include <bits/stdc++.h>#define int long longusing namespace std;const int maxn=1e9+5;bool visi[maxn];vector <int> prime;void sushu(){ for(int i=2;i*i<maxn;i++) if(!visi[i]) for(int j=i*i;j<maxn;j+=i) visi[j] = true; for(int...
2025 1.20~1.26
codeforces 991 div.3 A 题目 字符串处理,题意大概是:给你一个数字,问你有多少个完整的单词的字母数之和不超过这个数字。很简单的字符串题,运用字符串的size()函数即可。 代码 123456789101112131415161718192021222324#include <bits/stdc++.h>using namespace std;int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int t; cin >> t; while(t--){ int n,m,sum=0; string s; cin >> n >> m; while(n--){ cin >> s; int len = s.size(); m-=len; ...