NOIp #1 Life Big Bang Edition stone Scissors cloth Label: Analog

Source: Internet
Author: User

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 # #:
10 5 60 1 2 3 40 3 4 2 1 0
Sample # # of output:
6 2
Input Sample #:
9 5 50 1 2 3 41 0 3 2 4
Output Example #:
4 4
Description

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

Code
1#include <iostream>2#include <cstring>3#include <cstdio>4#include <algorithm>5 using namespacestd;6 7 inttrans[Ten][Ten]={8{0,0,1,1,0},9{1,0,0,1,0},Ten{0,1,0,0,1}, One{0,0,1,0,1}, A{1,1,0,0,0}, - }; -  the intN,MA,MB; - inta[999],b[999]; - intANSA,ANSB; -  + intMain () { -Freopen ("rps.in","R", stdin); +Freopen ("Rps.out","R", stdout); A      atscanf"%d%d%d",&n,&ma,&MB); -      for(intI=1; i<=ma;i++) scanf ("%d",&a[i]); -      for(intI=1; i<=mb;i++) scanf ("%d",&b[i]); -      -      for(intI=1; i<=n;i++){ -         intx=a[(i%ma==0)? ma:i%ma],y=b[(i%mb==0)? mb:i%MB]; inansa+=Trans[x][y]; -ansb+=Trans[y][x]; to     } +printf"%d%d\n", ANSA,ANSB); -     return 0; the}

NOIp #1 Life Big Bang Edition stone Scissors cloth Label: Analog

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.