题目
传送门:QWQ
A:A - Hit the Lottery
分析:
大水题 模拟
代码:
#include <bits/stdc++.h> using namespace std; int main(){ int n; int x=0;scanf("%d",&n); while(n>=100){ x++; n-=100; } while(n>=20){ x++; n-=20; } while(n>=10){ x++; n-=10; } while(n>=5){ x++; n-=5; } printf("%d ",x+n); }
B:B - World Cup
分析:
把之前无用的循环全部减掉,最后暴力模拟一下就ok
代码:
#include <bits/stdc++.h> using namespace std; const int maxn=2000005; int a[maxn]; int main(){ int n,minv=1e9+5;scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); minv=min(minv,a[i]); } // printf("========= %d ",minv); int k=0; for(;k<minv;k+=n); k=max(0,k-n); for(int i=1;i<=n;i++) a[i]-=k; // printf("====== %d ",k); int kkk=0; for(;;) for(int i=1;i<=n;i++){ // printf("------- %d: %d ",i,a[i]); if(a[i]-kkk<=0){ printf("%d ",i); return 0; } kkk++; } }
C:Tesla
分析:
代码:
D:D - Suit and Tie
分析:
贪心+暴力。
扫一遍,把另外一个位置的数暴力swap过来
代码:
#include <bits/stdc++.h> using namespace std; const int maxn=300; int a[maxn], ok[maxn]; int main(){ int n;scanf("%d",&n); n*=2; for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } int ans=0; for(int i=1;i<=n;i++){ if(ok[a[i]]) continue; int j; ok[a[i]]=1; for(j=i+1;j<=n;j++){ if(a[j]==a[i]) break; } // printf("--------- %d ",j); for(int k=j;k>=i+1;k--){ swap(a[k],a[k-1]); } ans+=j-i-1; } // for(int i=1;i<=n;i++) printf("%d ",a[i]); printf("%d",ans); return 0; }
E:E - Leaving the Bar
分析:
https://blog.csdn.net/deerly_/article/details/80857901
代码:
#include <bits/stdc++.h> using namespace std; const int maxn=100005; typedef long long ll; int ans[maxn]; ll sqr(ll x){return x*x; } struct Node{ ll x,y,id; }s[maxn]; int main(){ int n; scanf("%d",&n ); ll P=1500000; P=P*P; ll sumx=0,sumy=0; for(int i=1;i<=n;i++){ scanf("%I64d%I64d",&s[i].x,&s[i].y); s[i].id=i; } for(;;){ random_shuffle(s+1,s+1+n); ll X=0,Y=0; memset(ans,0,sizeof(ans)); for(int i=1;i<=n;i++){ ll valx=s[i].x,valy=s[i].y; if(sqr(X-valx)+sqr(Y-valy) > sqr(X+valx) + sqr(Y+valy)){ X+=valx; Y+=valy; ans[s[i].id]=-1; } else{ X-=valx; Y-=valy; ans[s[i].id]=1; } } if(sqr(X)+sqr(Y)<=P){ for(int i=1;i<=n;i++) printf("%d ",ans[i]); return 0; } } }