NOIP201405 Life Big Bang version stone scissors cloth

Source: Internet
Author: User

Question 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.

td> loss
a \ b scissors stone cloth lizard man Spock
scissors Flat output win win output
stone x Flat win output
cloth x x flat output win
lizard man x x x flat win
Spock x x x x flat

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-- ... "And if little B punches with the length of" scissors-stone-cloth-lizard man "for 5, then the sequence of his punch is" scissors-stone-cloth-the Lizard man-scissors-stone-cloth-rock-lizard man-...... "

It is known that small A and small B are carried out altogetherN times scissors. Every time a winning person has to1 points, 0 points to lose, and a draw for both of them 0 points. Now, please count the scores of the two people after the N-times scissors ended.

Input format

The first line consists of three integers: N< Span id= "mathjax-span-25" class= "Mo" >, na , Nb, respectively, for a total   n  times scissors, small A-punch cycle length, small B punch cycle length. The number and number are separated by a space.

The second line contains na integers, representing the law of small a punch, the third line contains nb integers, indicating the law of 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.

Sample One input
10 5 60 1 2 3 40 3 4 2 1 0
Output
6 2
Sample two input
9 5 50 1 2 3 41 0 3 2 4
Output
4 4

Simple violence.
1#include <iostream>2 3 using namespacestd;4 inta[201],b[201];5 ints[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};//refer to the 5*5 table in the topic. So the result of this array is the outcome.6 intMain ()7 {8     intn,a,b;9scanf"%d%d%d",&n,&a,&B);Ten      for(intI=0; i<a;i++) scanf ("%d",&a[i]); One      for(intI=0; i<b;i++) scanf ("%d",&b[i]); A     intans1=0, ans2=0; -      for(intI=0; i<n;i++) -     { the         intT1=A[I%A],T2=B[I%B];//since both A and b each have cycles, the method used to determine the current position corresponds to which of the cycles.  -ANS1+=S[T1][T2];//the outcome of A and B is the opposite. -ans2+=S[T2][T1]; -     } +printf"%d%d", ans1,ans2); -     //System ("pause"); +     return 0; A}
NOIP201405 Life Big Bang version stone scissors cloth

NOIP201405 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.