The Big Bang Theory Rock Paper Scissors

The Big Bang Theory Rock Paper Scissors

      #This test question can be found in Luogu#



1. The Big Bang Theory Edition Rock Paper Scissors

Time and space limit 1000ms / 128MB

Topic description

Rock-paper-scissors is a common guessing game: rock beats scissors, scissors beats paper, and paper beats rock. If the two punches are the same, there is no winner. An updated version of rock-paper-scissors appears in episode 8 of season two of The Big Bang Theory.

The upgraded version of the game adds two new gestures to the traditional rock-paper-scissors game:

Spock: One of the protagonists of Star Trek.

Lizardmen: The villain in Star Trek.

The relationship between the winners and losers of these five gestures is shown in Table 1, which lists the game results of A versus B.

 

Now, Little A and Little B try to play this upgraded version of the guessing game. It is known that their punches are cyclical, but the cycle lengths are not necessarily equal. For example: if little A punches in a cycle of "rock-paper-rock-scissors-lizard-man-spock" length 6, then his punch sequence is "rock-paper-rock-scissors-lizardman-spock" - rock-paper-rock-scissors-lizardman-spock-...", and if little B punches in a cycle of "scissors-rock-paper-spock-lizardman" length 5, then he punches The sequence is "Scissors - Rock - Boo - Spock - Lizardman - Scissors - Rock - Boo - Spock - Lizardman -..."

It is known that A and B have a total of N punches. Each time the winner gets 1 point, the loser gets 0 points; both players get 0 points for a tie. Now please count the scores of the two people after N times of guessing.

Input and output format

Input format:

The input file name is rps.in.

The first line contains three integers: N , NA, NB, which represent N times of guessing, the period length of small A's punches, and the period length of small B's punches. Separate numbers with a space.

The second line contains NA integers, indicating the regularity of small A's punches, and the third line contains NB integers, indicating the regularity of small B's punching. Where 0 means "scissors", 1 means "rock", 2 means "cloth", 3 means "lizardmen", and 4 means "spock". Separate numbers with a space.

Output format:

The output file is named rps.out.

Output a line containing two integers, separated by a space, representing the scores of small A and small B respectively.

Input and output example

Input sample #1 : 

10 5 6

0 1 2 3 4

0 3 4 2 1 0

Sample output #1 : 

6 2

 

illustrate

For 100% of the data, 0 < N ≤ 200 , 0 < NA ≤ 200 , 0 < NB ≤ 200 .



 



This question day1 first question

There is nothing to say, if more, be patient

Daniel didn't read such a question, so let's talk about it.

I gave half of the form, and the other half is also considered, I almost forgot

 

The table is 5*5, with a total of 25 possibilities.

Remove the tie without extra points

20 more

Write out which of the five a and b can win ansa++

b also

 

ps:

When reading, put the last element into element 0

Because the reading is the cycle law, it needs to be used multiple times, and the % cycle length is not allowed.

Just think about it 1%x==1 2%x==2... x%x==0

When x%x, we want the value of x, but we get 0

Simply give the value of a[x] to a[0], so that you can get any corresponding value in the cycle directly by i%x

With AC code

 




 


#include<cstdio>
#define maxn 300
using namespace std;
int n,na,nb;
int a[maxn],b[maxn],ansa,ansb;
int main()
{
    //freopen("rps.in","r",stdin);
    //freopen("rps.out","w"stdout);
    scanf("%d%d%d",&n,&na,&nb);//读入n,na,nb
    for(int i=1;i<=na;++i)
        scanf( " %d " ,&a [i]);//The order of reading a and b respectively
     for ( int i= 1 ;i<=nb;++ i)
        scanf("%d",&b[i]);
    a[ 0 ]= a[na];//Here, put the last element of a and b into element 0
    b[ 0 ]= b[nb];//The above solution has mentioned
     for ( int i= 1 ;i<=n;++ i)
    {
        if (a[i%na]== 0 &&(b[i%nb]== 2 ||b[i%nb]== 3 )) {ansa++; continue ;}//Determine the possible situations where a can win , if true,
         if (a[i%na]== 1 &&(b[i%nb]== 0 ||b[i%nb]== 3 )) {ansa++; continue ;}//ans++ continue
         if (a[i%na]== 2 &&(b[i%nb]== 1 ||b[i%nb]== 4 )) {ansa++; continue ;}//if can be written as 2 or 20
         if (a[i%na]== 3 &&(b[i%nb]== 2 ||b[i%nb]== 4 )) {ansa++; continue ;}//If it's not awkward
        if(a[i%na]==4&&(b[i%nb]==0||b[i%nb]==1)) {ansa++;continue;}
        
        if(b[i%nb]==0&&(a[i%na]==2||a[i%na]==3)) {ansb++;continue;}//同上
        if(b[i%nb]==1&&(a[i%na]==0||a[i%na]==3)) {ansb++;continue;}
        if(b[i%nb]==2&&(a[i%na]==1||a[i%na]==4)) {ansb++;continue;}
        if(b[i%nb]==3&&(a[i%na]==2||a[i%na]==4)) {ansb++;continue;}
        if(b[i%nb]==4&&(a[i%na]==0||a[i%na]==1)) {ansb++;continue;}
    }
    printf("%d %d",ansa,ansb);//直接输出就可以了 
    return 0;    
} 

 


 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324609495&siteId=291194637