2024下 第18周12.30~1.5
codeforces 995 div3 A 题目 贪心,要使m-s差最大化,就让每个大于零的ai-b(i+1 )相加,并加上a[n-1],就是最大值 代码 123456789101112131415161718192021222324252627#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 a[101],b[101],cache,n,sum=0; cin >> n; for(int i=0;i<n;i++){ cin >> cache; a[i]=cache; } for(int...
2024下 第17周12.23~12.29
codeforces 993 div4 A 题目 给你一个n,问你有多少有序数对(a,b)满足a+b=n? 其实就是n-1 代码 1234567891011121314#include <bits/stdc++.h>using namespace std;int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int t,n; cin >> t; while(t--){ cin >> n; cout << n-1 << '\n'; } return 0;} B 题目 这个人在店铺外面看窗上的字母是"qwq",问你在店铺里面看窗子上是什么字母? 逆序输出,q变p,p变q,w不变 代码 12345678910111213141516171819#include...
2024下 第16周12.16~12.22
codeforces 988 div.3 A 题目 找相同的数字,有点像天天爱消除,两个相同的数字就可以消掉,用个数组记录数字出现的次数就ok。这题数据很小,什么方法都行 代码 1234567891011121314151617181920212223242526#include <bits/stdc++.h>using namespace std; int t,score,n,cache,a[21]; int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin >> t; while(t--){ cin >> n; fill_n(&a[0],21,0);score=0; for(int i=0;i<n;i++){ cin >> cache; a[cache-1]++; ...
2024下 第15周12.9~12.15
codeforces 859 div4 A 题目 签到题,没有算法,纯if判断然后输出 代码 12345678910111213141516#include <bits/stdc++.h>using namespace std;int t,a,b,c;int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin >> t; for(int i=0;i<t;i++){ cin >> a >> b >> c; if(a+b == c) cout << "+" <<'\n'; else cout << "-" <<'\n'; } return...
2024下 第14周12.2~12.8
codeforces 22 div2(喔被豹纱了) A 题目 签到题,利用set的互异性和自动排序就可以 代码 12345678910111213141516171819#include <bits/stdc++.h>using namespace std;int n,ip;set <int> s;int main(void){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin >> n; for(int i=0;i<n;i++){ cin >> ip; s.insert(ip); } set<int>::iterator it; it = s.begin();it++; if(it!=s.end()) cout << *it; else cout << "NO"; return...
Hello-World
新的方案!我的博客网站在地球上诞生了! Hello World!