div4_971Codeforces Round 971 (Div. 4) 题解
A. Minimize!
输出\(b-a\)即可
code:
123456789101112131415161718#include <bits/stdc++.h>using namespace std;int T;int a, b;int main(){ cin >> T; while (T--) { cin >> a >> b; cout << b - a << endl; } return 0;}
B. osu!mania
从下到上,从左到右遍历字符串,输出每个\(\#\)在当前行的位置
code:
123456789101112131415161718192021222324252627#include <bits/stdc++.h>using namespace std;const int N = 510;int T;int n;string s[N];int main(){ ci ...
牛客周赛 Round 58 题解
A. 会赢吗?
签到,比大小
code:
123456789101112131415#include <bits/stdc++.h>using namespace std;double a, b;int main(){ cin >> a >> b; if (a < b) cout << "YES" << endl; else cout << "NO" << endl; return 0;}
B. 能做到的吧
判断是否有\(i,j\)满足\(1<=i<j<=n\),并且\(s[i]<s[j]\),如果有就输出\(YES\),否则输出\(NO\)
code:
1234567891011121314151617181920212223242526272829303132#include <bits/stdc++.h>using namespace std;int T;s ...
Codeforces Round 969 (Div. 2) 题解
A. Dora's Set
要使三个数互质,那么一定是两个奇数\(+\)一个偶数,因此遍历\(l\)到\(r\),每次删除相邻的奇偶奇序列即可
code:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576#include <bits/stdc++.h>#define int long longusing namespace std;int T;int n, m;signed main(){ cin >> T; while (T--) { cin >> n >> m; int res = 0; while (n <= m) { if (n % 2 == 0) n ...
Codeforces Round 970 (Div. 3) 题解
A. Sakurako's Exam
签到,优先考虑\(2\)之间互相加减,所以只会剩下最多一个\(2\),用\(2\)个\(1\)来消除,最后判断剩下\(1\)的个数即可
code:
1234567891011121314151617181920212223242526272829#include <bits/stdc++.h>#define int long long#define x first#define y secondusing namespace std;typedef pair<int, int> PII;const int N = 200010;int T;int a, b;signed main(){ cin >> T; while (T--) { cin >> a >> b; b %= 2; a -= b * 2; if (a < 0 || a % 2) cout << "NO&qu ...
Codeforces Round 968 (Div. 2) 题解
A. Turtle and Good Strings
根据题意可知,一个好的字符串一定可以拆成两个满足条件的字符串,所以只需要令\(k=2\)进行操作即可
code:
123456789101112131415161718192021222324252627282930313233#include <bits/stdc++.h>#define int long long#define x first#define y second#define endl '\n'using namespace std;typedef pair<int, int> PII;const int N = 200010;int T;int n;string s;signed main(){ ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> T; while (T--) { cin >> n >> ...
Codeforces Round 966 (Div. 3) 题解
A. Primary Task
暴力判断即可
code:
1234567891011121314151617181920212223242526272829303132333435363738394041#include <bits/stdc++.h>#define x first#define y second#define int long longusing namespace std;typedef pair<int, int> PII;const int N = 200010;int T;int n;int a[N];signed main(){ cin >> T; while (T--) { cin >> n; string s; while (n > 10) { s += n % 10 + '0'; n /= 10; ...
Educational Codeforces Round 169 (Rated for Div. 2) 题解
A. Closest Point
观察一下可以发现,只有当集合中的点数等于\(2\),并且这两个点的差值大于\(1\)时,才有满足条件的点可以插入
code:
123456789101112131415161718192021222324252627282930#include <bits/stdc++.h>#define int long long#define x first#define y secondusing namespace std;typedef pair<int, int> PII;const int N = 200010;int T;int n;int a[N];signed main(){ cin >> T; while (T--) { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; if (n == 2 && abs(a[0] - a[1]) > ...
河南萌新联赛 2024 第(五)场 题解
A. 日历游戏
\(sg\) 函数板子题,就是需要多处理一个日期
code:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283#include <bits/stdc++.h>using namespace std;int T;int y, m, d;int bg, ed;map<int, int> f;int mon[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};bool check(int y){ return (y % 4 == 0 && y % 100) || y % 400 == 0;}int get_day(int y, int m, int d){ ...
河南萌新联赛2024第(四)场 题解
A. 该出奇兵了
$tarjan \(割点板子题,处理完割点以后\)dfs$ 求出每个点被删掉以后对答案的最小贡献
code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130#include <bits/stdc++.h>#define int __int128using namespace std;const int N = 100010;int n, m;int a[N];vector<int> h[N];int dfn[N], low[N], to ...