【队伍训练】Codeforces Round #660 (Div. 2)
程序员文章站
2022-06-27 18:36:55
A思维#pragma GCC target("avx,sse2,sse3,sse4,popcnt")#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")#include using namespace std;#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)typedef long lon...
A
思维
#pragma GCC target("avx,sse2,sse3,sse4,popcnt") #pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math") #include <bits/stdc++.h> using namespace std; #define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0) typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ll MOD = 1e9 + 7; inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (ch < 48 || ch > 57) { if (ch == '-') w = -1; ch = getchar(); } while (ch >= 48 && ch <= 57) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar(); return s * w; } inline void write(ll x) { if (!x) { putchar('0'); return; } char F[40]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-'); int cnt = 0; while (tmp > 0) { F[cnt++] = tmp % 10 + '0'; tmp /= 10; } while (cnt > 0)putchar(F[--cnt]); } inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll qpow(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans *= a; b >>= 1; a *= a; } return ans; } ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; } inline int lowbit(int x) { return x & (-x); } int main(){ int t; cin>>t; while(t--){ int n; cin>>n; if(n<=30) cout<<"NO"<<endl; else if(n==36) cout<<"YES\n"<<"5 6 10 15"<<endl; else if (n==40) cout<<"YES\n"<<"2 6 10 22"<<endl; else if (n==44) cout<<"YES\n"<<"2 6 10 26"<<endl; else cout<<"YES\n"<<"6 10 14 "<<n-30<<endl; } }
B
观察
#pragma GCC target("avx,sse2,sse3,sse4,popcnt") #pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math") #include <bits/stdc++.h> using namespace std; #define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0) typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ll MOD = 1e9 + 7; inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (ch < 48 || ch > 57) { if (ch == '-') w = -1; ch = getchar(); } while (ch >= 48 && ch <= 57) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar(); return s * w; } inline void write(ll x) { if (!x) { putchar('0'); return; } char F[40]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-'); int cnt = 0; while (tmp > 0) { F[cnt++] = tmp % 10 + '0'; tmp /= 10; } while (cnt > 0)putchar(F[--cnt]); } inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll qpow(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans *= a; b >>= 1; a *= a; } return ans; } ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; } inline int lowbit(int x) { return x & (-x); } int main(){ int t; cin>>t; int n; while(t--){ cin>>n; int len=4*n-n; for (int i=0;i<(len/4);i++) cout<<9; for (int i=(len/4);i<n;i++) cout<<8; cout<<endl; } return 0; }
C
dfs
这题卡时间较长
#include<bits/stdc++.h> #define maxn 100100 using namespace std; vector<int> g[maxn]; int happy[maxn]; int all[maxn]; int diff[maxn]; int flag; int f; void dfs(int v, int p) { int h = 0,k = 0; for (auto u : g[v]){ k += 1; if (u == p) { continue; } dfs(u, v); all[v] += all[u]; h += happy[u]; } happy[v] = all[v] - (all[v] - diff[v]) / 2; if (happy[v] < h || happy[v]<0||happy[v]>all[v] || all[v]%2!=(diff[v]%2+2)%2) { f = 0; } } int main(){ int t; cin>>t; while(t--){ f = 1; int n,m; cin>>n>>m; for (int i = 0; i < n; i++) { cin >> all[i];//每个人住在哪 g[i].clear(); } for (int i = 0; i < n; i++) { cin >> diff[i];//给定的对照值 } for (int i=0;i<n-1;i++){//建图 int a, b; cin>>a>>b; a--; b--; g[a].push_back(b); g[b].push_back(a); } dfs(0, -1); if(f) cout << "YES"<<endl; else cout << "NO" <<endl; } return 0; }
D
不太理解,队友做了
本文地址:https://blog.csdn.net/qq_45585519/article/details/107900593
上一篇: 刘备号称贤德之君,为什么不愿意回东吴?
下一篇: 朱元璋养兵百万真的没花钱吗?全靠此制度
推荐阅读
-
Codeforces Round #222 (Div. 2)
-
Codeforces Round #435 (Div. 2)-B. Mahmoud and Ehab and the bipartiteness
-
Codeforces Round #279 (Div. 2) 解题报告_html/css_WEB-ITnose
-
Codeforces Round #340 (Div. 2)-E-XOR and Favorite Number(莫队)
-
Codeforces Round #482 (Div. 2) D. Kuro and GCD and XOR and SUM(数学+01字典树)(好题)
-
Codeforces Round #553 (Div. 2) B. Dima and a Bad XOR(异或+思维)
-
Codeforces Round #246 (Div. 2) ?B. Football Kit_html/css_WEB-ITnose
-
Codeforces Round #261 (Div. 2)B. Pashmak and Flowers(容易)
-
Educational Codeforces Round 41 (Rated for Div. 2) E. Tufurama(树状数组+偏序)
-
Educational Codeforces Round 37 (Rated for Div. 2) E. Connected Components?(图论+连通块+bfs)