cogs luogu [NOIP2014]生活大爆炸版石头剪刀布

1803. [NOIP2014]生活大爆炸版石头剪刀布

★   输入文件:rps.in   输出文件:rps.out   简单对比
时间限制:1 s   内存限制:128 MB

 

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<cmath>
 5 
 6 using namespace std;
 7 const int N=210;//a: 0 ping  1 shu   2 ying
 8 const int c[5][5]={ 0,1,2,2,1,
 9                     2,0,1,2,1,
10                     1,2,0,1,2,
11                     1,1,2,0,2,
12                     2,2,1,1,0 };
13 
14 int a[N];
15 int b[N];
16 int Answera;
17 int Answerb;
18 
19 inline int read()
20 {
21     int x=0,f=1;
22     char c=getchar();
23     while(c<'0'||c>'9') {if(c=='-')f=-1; c=getchar();}
24     while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
25     return x*f;
26 }
27 
28 int main()
29 {
30     freopen("rps.in","r",stdin);
31     freopen("rps.out","w",stdout);
32     
33     int n=read();
34     int la=read();
35     int lb=read();
36     for(int i=1;i<la;i++)
37         a[i]=read();
38     a[0]=read();
39     for(int i=1;i<lb;i++)
40         b[i]=read();
41     b[0]=read();
42     
43     for(int i=1;i<=n;i++)
44     {
45         if(c[a[i%la]][b[i%lb]]==2)Answera++;
46         if(c[a[i%la]][b[i%lb]]==1)Answerb++;
47     }
48     
49     printf("%d %d",Answera,Answerb);
50     return 0;
51 }

 

posted @ 2017-05-25 15:46  ioioioioioio  阅读(158)  评论(0编辑  收藏  举报