-
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, the two sides played 4 rounds, so a won more rounds.
-
1#include <iostream>2 using namespacestd;3 4 intMain () {5 intCount,cyclea,cycleb;6Cin>>count>>cyclea>>Cycleb;7 intawin=0, bwin=0;8 Chararraya[ -];9 Chararrayb[ -];Ten for(intI=0; i<cyclea;i++) OneCin>>Arraya; A for(intI=0; i<cycleb;i++) -Cin>>Arrayb; - for(intI=0; i<count;i++){ the if((arraya[i%cyclea]=='0'&& arrayb[i%cycleb]=='2')|| -(arraya[i%cyclea]=='2'&& arrayb[i%cycleb]=='5')|| -(arraya[i%cyclea]=='5'&& arrayb[i%cycleb]=='0')) -awin++; + Else if((arraya[i%cyclea]=='2'&& arrayb[i%cycleb]=='0')|| -(arraya[i%cyclea]=='5'&& arrayb[i%cycleb]=='2')|| +(arraya[i%cyclea]=='0'&& arrayb[i%cycleb]=='5')) Abwin++; at } - if(Awin >bWin) -cout<<"A"; - Else if(Awin <bWin) -cout<<"B"; - Else incout<<"Draw"; -cout<<Endl; to}
View Code
The main problem is that when the input sequence is first entered, it is not truncated according to the length of sequence A, resulting in an incorrect result when a, B enters the same sequence, always judged to be a victory. When the input sequence is entered according to the length of the previous step, the result is OK
Hundred Practice stone scissors cloth