赞
踩
#include <bits/stdc++.h> //#define int long long const int N = 4e5+10; const int mod = 1e9+7; using namespace std; int n,m,s,d; int res = 0; signed main(){ int t = 1; cin>>t; while(t--){ int a,b,c; cin>>a>>b>>c; if((a+b+c)%9 == 0 && min(c,min(a,b)) >= (a+b+c)/9){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } } return 0; }
#include <bits/stdc++.h> //#define int long long const int N = 4e5+10; const int mod = 1e9+7; using namespace std; int n,m,s,d; int res = 0; int a[N]; signed main(){ int t = 1; cin>>t; while(t--){ cin>>n; for(int i = 0 ; i < n ; i ++) cin>>a[i]; int sum = 0; for(int i = 0 ; i < n ; i ++) sum += a[i]; int pre = a[0]; cout<<pre<<" "; for(int i = 1 ; i < n ; i ++){ int now = (a[i]/pre)*pre; now = now==0 ? 1 : now; cout<<now<<" "; pre = now; } cout<<endl; } return 0; }
#include <bits/stdc++.h> #define int long long const int N = 4e5+10; const int mod = 1e9+7; using namespace std; int n,m,s,d; int res = 0; struct node{ int t,x; node(){} node(int tt,int xx){t=tt,x=xx;} }a[N]; signed main(){ int t = 1; cin>>t; while(t--){ cin>>n; for(int i = 0 ; i < n ; i ++){ int ti; int x; cin>>ti>>x; a[i] = node(ti,x); } a[n].x = a[n-1].x; a[n].t = 1e17; int now = 0; // current position int res = 0; // the ans int busy = 0; // flag int command = 0; // last command int time = 0; // past time int need = 0; // time needed for walk for(int i = 0 ; i <= n ; i ++){ if(!busy){ time = 0; busy = 1; command = i; need = abs(a[i].x-now); }else{ time += a[i].t-a[i-1].t; // past time if(time >= need){ if(i-command == 1){ res++; //cout<<a[i].t<<" -111- "<<a[i].x<<endl; //cout<<"pre : "<<a[command].t<<" "<<a[command].x<<endl; } now = a[command].x; time = 0; command = i; need = abs(a[i].x-now); }else{ if(a[i].x < now && a[command].x < now){ if(abs(a[i].x - now) >= time && abs(a[i].x - now) <= time+a[i+1].t-a[i].t && abs(a[i].x - now) <= need){ res++; //cout<<a[i].t<<" -222- "<<a[i].x<<endl; //cout<<"pre c: "<<a[command].t<<" "<<a[command].x<<" now"<<now<<endl; } }else if(a[i].x > now && a[command].x > now){ if(abs(a[i].x - now) >= time && abs(a[i].x - now) <= time+a[i+1].t-a[i].t && abs(a[i].x - now) <= need){ res++; //cout<<a[i].t<<" -222- "<<a[i].x<<endl; //cout<<"pre c: "<<a[command].t<<" "<<a[command].x<<" now"<<now<<endl; } } } } } cout<<res<<endl; } return 0; }
#include <bits/stdc++.h> #define int long long #define pb push_back const int N = 4e5+10; const int mod = 1e9+7; using namespace std; int n,m,s,d; int res = 0; int a[N]; int mark[N]; vector<int> v1; vector<int> v2; int check(int mid){ for(int i = 0 ; i < mid ; i ++){ if(v1[i] > v2[n-mid+i]) return 1; } for(int i = 0 ; i < n - mid ; i ++){ if(v1[i+mid] < v2[i]) return 2; } return 0; } signed main(){ int t = 1; cin>>t; while(t--){ cin>>n; v1.clear(); v2.clear(); for(int i = 1 ; i <= 2*n ; i ++){ mark[i] = 0; } for(int i = 0 ; i < n ; i ++){ cin>>a[i]; mark[a[i]] = 1; } for(int i = 1 ; i <= 2*n ; i ++){ if(mark[i]) v1.pb(i); else v2.pb(i); } int l = 0,r = n; int L = n,R = n; while(l <= r){ int mid = (l+r)>>1; if(check(mid) != 2){ L = mid; r = mid-1; }else{ l = mid+1; } } l = 0,r = n; while(l <= r){ int mid = (l+r)>>1; if(check(mid) != 1){ R = mid; l = mid+1; }else{ r = mid-1; } } cout<<(R-L+1)<<endl; } return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。