P1905 Life Big Bang version stone scissors cloth

Source: Internet
Author: User

 P1905 Life Big Bang version stone scissors clothDescribe

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 punches with a 6-length cycle of "stone-cloth-stone-scissors-lizard Man-Spock", then his punch sequence is "stone-cloth-stone-scissors-lizard man-rock-stone-cloth-stone-scissors-lizard man-Spock-......", and if Little B takes " 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-lizard man-...... "

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.

Format input Format

The first line contains three integers: N,NA,NB, representing the period length of a total of N times scissors, 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

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

Example 1 sample input 1[copy]
10 5 60 1 2 3 40 3 4 2 1 0
Sample output 1[Copy]
6 2
Example 2 sample input 2[copy]
9 5 50 1 2 3 41 0 3 2 4
Sample output 2[Copy]
4 4
Limit

For 100% of data, 0 < n≤200,0 < na≤200, 0 < nb≤200.

Source

NOIP2014 Raising Group Day1

There's no need to explain, just read the rules.

AC Code

#include <cstdio> #include <iostream>using namespace Std;int n,na,nb;int rule[5][5]={{0,0,1,1,0},{ 1,0,0,1,0},{0,1,0,0,1},{0,0,1,0,1},{1,1,0,0,0}};int a[205],b[205];int score_a,score_b;int Main () {cin>>n> >na>>nb;for (int i=0;i<na;i++) scanf ("%d", &a[i]), for (int i=0;i<nb;i++) scanf ("%d", &b[i]); (int i=0;i<n;i++) {int ges_a=a[i%na];int ges_b=b[i%nb];score_a+=rule[ges_a][ges_b];score_b+=rule[ges_b][ges_a];} printf ("%d%d", score_a,score_b); return 0;}

  

P1905 Life Big Bang version stone scissors cloth

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.