Life Big Bang version stone scissors cloth

Source: Internet
Author: User

NOIp2014 Raise Group

Address: http://www.luogu.org/problem/show?pid=1328

"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 and 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 Sample # #:

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.

"Ideas"

In view of the data are very small, this problem with a simulated naïve algorithm can be too, hit a table to calculate the situation of different boxing, encountered in the situation to judge.

ConstSco:Array[0..4,0..4] ofLongint=((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));varB:Array[1.. $] ofLongint; Na,nb,la,lb,n,i:longint;beginreadln (N,LA,LB);  fori:=1  toLa Doread (a[i]);  fori:=1  toLb Doread (b[i]);  fori:=1  toN Do         beginInc (na,sco[a[(i-1)MoDLA) +1],b[((I-1)MoDLB) +1]]); Inc (Nb,sco[b[(i-1)MoDLB) +1],a[((I-1)MoDLA) +1]]); End; Writeln (Na,' ', NB);End.

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.