luogu1328 [NOIp2014]生活大爆炸版石头剪刀布 (模拟)
1 #include<bits/stdc++.h> 2 #define pa pair<int,int> 3 #define CLR(a,x) memset(a,x,sizeof(a)) 4 using namespace std; 5 typedef long long ll; 6 const int maxn=220; 7 8 inline ll rd(){ 9 ll x=0;char c=getchar();int neg=1; 10 while(c<'0'||c>'9'){if(c=='-') neg=-1;c=getchar();} 11 while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar(); 12 return x*neg; 13 } 14 15 int N,A,B; 16 int opa[maxn],opb[maxn]; 17 int res[10][10]={{0,-1,1,1,-1}, 18 {1,0,-1,1,-1}, 19 {-1,1,0,-1,1}, 20 {-1,-1,1,0,1}, 21 {1,1,-1,-1,0}}; 22 int ansa,ansb; 23 24 int main(){ 25 //freopen(".in","r",stdin); 26 int i,j,k; 27 N=rd(),A=rd(),B=rd(); 28 for(i=0;i<A;i++) opa[i]=rd(); 29 for(i=0;i<B;i++) opb[i]=rd(); 30 for(i=0;i<N;i++){ 31 int x=res[opa[i%A]][opb[i%B]]; 32 if(x==1) ansa++; 33 else if(x==-1) ansb++; 34 } 35 printf("%d %d\n",ansa,ansb); 36 return 0; 37 }