//A #include<iostream> #include<cstring> #include<cstdio> using namespace std; int num[300]; int main(){ num[1] = 1; num[2] = 3; for(int i=3;i<200;i++){ num[i] = num[i-1] + i; // cout<<i<<" "<<num[i]<<endl; } int n; scanf("%d",&n); int ans = 0,k=1; while(n-num[k]>=0){ n-=num[k++]; ans++; } cout<<ans<<endl; return 0; }
?
//B #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; ll num[1010]; ll n,l; int main(){ while(scanf("%I64d%I64d",&n,&l)!=EOF){ ll mds = 0; num[0] = 0; for(int i=1;i<=n;i++){ scanf("%I64d",&num[i]); } sort(num+1,num+n+1); for(int i=2;i<=n;i++) mds = max(mds , num[i]- num[i-1]); // cout<<mds<<endl; double res = (mds*1.0)/2; res = max(res ,(l*1.0)-(num[n]*1.0)); res = max(res,num[1]*1.0); printf("%.10lf\n",res); } return 0; }
?
//C #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> ////////// #include<cmath> using namespace std; typedef long long ll; struct axx{ long long a,b; }node[100100]; bool cmp(axx a,axx b){ if(a.b<b.b)return 1; return 0; } ll r,avg; int n; int main(){ while(cin>>n>>r>>avg){ long long tot=0; for(int i = 1 ;i<=n; i++){ scanf("%I64d%I64d",&node[i].a,&node[i].b); tot += node[i].a; } ll need = avg*n-tot; if(need<=0ll){ cout<<0<<endl; continue; } sort(node+1,node+n+1,cmp); ll ans =0; for(int i = 1;i<=n;i++){ ll can = (r-node[i].a); if(can>=need){ ans+=need*node[i].b; break; }else{ ans+=can*node[i].b; need -=can; } } cout<<ans<<endl; } return 0; }
?
//D #include<iostream> #include<cstring> #include<cstdio> using namespace std; typedef long long ll; const ll nMax = 10010000; ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); } int isvya[nMax]; void gao(ll x,ll y,ll ggd){ long long tmp = 0,a = 0, b = 0,k = 1; while(tmp != ggd){ if(x*(a+1)<y*(b+1)){ a++; isvya[k++] = 1; tmp = x*a; }else{ b++; isvya[k++] = 2; tmp = y * b; } } } int main(){ ll n,x,y,a; while(cin>>n>>x>>y){ ll gd = gcd(x,y); ll ggd = x/gd*y; gao(x,y,ggd); // cout<<ggd<<endl; ll ax = ggd/x + ggd/y; // cout<<ax<<endl; while(n--){ scanf("%I64d",&a); a = a % ax; if(a%ax == 0 || a%(ax - 1) == 0){ cout<<"Both\n"; continue; } if(isvya[a] == 2){ cout<<"Vanya"<<endl; }else{ cout<<"Vova"<<endl; } } } return 0; } /* 7 5 20 26 27 28 29 30 31 32 */
?
Codeforces Round #280 (Div. 2)
原文:http://bbezxcy.iteye.com/blog/2162372