Title Description
Stone scissors cloth is a common scissors game: Stone wins scissors, scissors wins cloth, Bushe stone. If two people punch the same, then dead heat. In the 8th episode of the second quarter of the Big Bang, a new version of the rock-and-scissors-cloth game appeared.
The upgraded version of the game is based on the traditional stone scissors cloth game, adding two new gestures:
Spock: One of the leading stars of Star Trek.
Lizard Man: The reverse role in Star Trek.
The outcome of these five gestures is shown in table one, and the table shows the results of a pair B game.
Now, small A and little B try to play this upgraded version of the scissors game. They are known to have a cyclical pattern, but the cycle length is not necessarily equal. For example, if small A is punched in the 6-length cycle of "stone-cloth-stone-scissors-lizard man-Spock" so his punch sequence is "rock-cloth-stone-scissors-lizard man-rock-stone-cloth-stone-scissors-lizard man--" and if little B with "scissors-- Stone-cloth-lizard Man "The length of the 5-period punch, then his punch sequence is" scissors-stone-cloth-the lizard-man-scissors-stone-cloth-rock-the lizard people-... "
It is known that small A and small b are scissors for n times altogether. Each winning person has 1 points, loses 0 points, the draw two people both have to have 0 points. Now, please count the scores of the two people after the N-times scissors ended.
Input/output format
Input format:
The input file name is rps.in.
The first line contains three integers: N, NA,NB, respectively, representing a total of n times scissors, the period length of the small a punch, and the period length of the small B punch. The number and number are separated by a space.
The second line contains Na integers, representing the law of small a punch, and the third line contains NB integers representing the law of the small B punch. Among them, 0 means "scissors", 1 means "stone", 2 means "cloth", 3 means "lizard Man", 4 means "rock". The number and number are separated by a space.
Output format:
The output file name is Rps.out.
Output a row, containing two integers, separated by a space, representing the score of small A and small B respectively.
Input and Output Sample input example # #:
5 6 0 1 2 3 4 0 3 4 2 1 0
Sample # # of output:
6 2
Input Sample #:
Output Example #:
4 4
Description
For 100% of data, 0 < n≤200, 0 < na≤200, 0 < nb≤200.
——————————————————————————————————————————————————————————
Water problem, pure mold
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6 using namespaceStd//0 means "scissors", 1 means "stone", 2 means "cloth", 3 means "lizard Man", 4 means "rock "7 intPdint,int);8 intMain ()9 {Ten intDa=0, db=0, s,n,na,nb,a[201]={0x7f},b[201]={0x7f},heada=0, taila=1, headb=0, tailb=1; Onecin>>n>>na>>nb;taila=na+1; tailb=nb+1; A for(intI=1; i<=na;i++) cin>>A[i]; - for(intI=1; i<=nb;i++) cin>>B[i]; - for(intI=1; i<=n;i++) the { -heada++;headb++; - if(Heada==taila) heada=1; - if(HEADB==TAILB) headb=1; +s=PD (A[HEADA],B[HEADB]); - if(s==1) da++; + if(s==-1) db++; As=0; at } -cout<<da<<" "<<db; - return 0; - } - intPdintCanintBB) - { in if(aa==0&&bb==0)return 0; - if(aa==0&&bb==1)return-1; to if(aa==0&&bb==2)return 1; + if(aa==0&&bb==3)return 1; - if(aa==0&&bb==4)return-1; the if(aa==1&&bb==0)return 1; * if(aa==1&&bb==1)return 0; $ if(aa==1&&bb==2)return-1;Panax Notoginseng if(aa==1&&bb==3)return 1; - if(aa==1&&bb==4)return-1; the if(aa==2&&bb==0)return-1; + if(aa==2&&bb==1)return 1; A if(aa==2&&bb==2)return 0; the if(aa==2&&bb==3)return-1; + if(aa==2&&bb==4)return 1; - if(aa==3&&bb==0)return-1; $ if(aa==3&&bb==1)return-1; $ if(aa==3&&bb==2)return 1; - if(aa==3&&bb==3)return 0; - if(aa==3&&bb==4)return 1; the if(aa==4&&bb==4)return 0; - if(aa==4&&bb==0)return 1;Wuyi if(aa==4&&bb==1)return 1; the if(aa==4&&bb==2)return-1; - if(aa==4&&bb==3)return-1; Wu}
View Code
Rokua P1328 Life Big Bang version stone scissors cloth--S.B.S.