c/c++语言开发共享【队伍训练】Codeforces Round #660 (Div. 2)

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 lon

A
思维

%ignore_pre_1%

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
不太理解,队友做了

c/c++开发分享【队伍训练】Codeforces Round #660 (Div. 2)地址:https://blog.csdn.net/qq_45585519/article/details/107900593

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请点击右边联系管理员删除。

如若转载,请注明出处:https://www.ctvol.com/c-cdevelopment/598139.html

(0)
上一篇 2021年5月8日
下一篇 2021年5月8日

精彩推荐