08: Stone Scissors Cloth
-
Total time limit:
-
1000ms
-
Memory Limit:
-
65536kB
-
Describe
-
Stone scissors cloth is a common scissors game. The stone wins the scissors, the scissors wins the cloth, Bushe the stone. If two people punch the same, then dead heat.
One day, small A and small b just play stone scissors cloth. It is known that their punches are cyclical, such as: "Stone-cloth-stone-scissors-stone-cloth-stone-scissors ..." is the cycle of "stone-cloth-stone-scissors". I ask, small A and small b than the N-wheel, who won the number of rounds?
-
Input
-
The input contains three rows.
The first line contains three integers: N,NA,NB, which represents the period length of the fist, and the period length of the small B punch, respectively, compared to the N wheel. 0 < N,NA,NB < 100.
The second line contains an NA integer representing the law of the small a punch.
The third line contains NB integers, indicating the law of the small B punch.
Of these, 0 means "stone", 2 means "scissors" and 5 means "cloth". Adjacent two integers are separated by a single space.
-
Output
-
Output a line if small a wins more rounds, output A; If small B wins more rounds, output B; If two people are flat, output draw.
-
Sample input
-
10 3 40 2 50 5 0 2
-
Sample output
-
A
-
Tips
-
For test data, the scissors process is:
a:0 2 5 0 2 5 0 2 5 0
b:0 5 0 2 0 5 0 2 0 5
A won 4 rounds, B won 2 rounds, both sides played 4 rounds, so a won more rounds
Ideas
Simulation
Come on, on the code:
#include <cstdio>using namespacestd;intn,na,nb,ca[101],cb[101],ans_a,ans_b,now_a=0, now_b=0;intMain () {scanf ("%d%d%d",&n,&na,&(b); for(intI=1; i<=na;i++) scanf ("%d",&Ca[i]); for(intI=1; i<=nb;i++) scanf ("%d",&Cb[i]); for(intI=1; i<=n;i++) {now_a++,now_b++; if(Now_a>na) now_a=1; if(NOW_B>NB) now_b=1; if(ca[now_a]==0&&cb[now_b]==2) ans_a++; if(ca[now_a]==0&&cb[now_b]==5) ans_b++; if(ca[now_a]==2&&cb[now_b]==0) ans_b++; if(ca[now_a]==2&&cb[now_b]==5) ans_a++; if(ca[now_a]==5&&cb[now_b]==0) ans_a++; if(ca[now_a]==5&&cb[now_b]==2) ans_b++; } if(ans_a>ans_b) printf ("a\n"); Else { if(ans_a<ans_b) printf ("b\n"); Else{printf ("draw\n"); } } return 0;}
AC Diary--stone scissors cloth Openjudge 1.6 08