「题解」Luogu 1328「生活大爆炸版剪刀石头布」

分析

这是一道模拟水题。

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<cstdio>
#include<vector>
int guess(int a,int b){
if(a == 0){
if(b ==0) return -1;
else if(b == 1) return 0;
else if(b == 2) return 1;
else if(b == 3) return 1;
else if(b == 4) return 0;
}else if(a == 1){
if(b == 0) return 1;
else if(b == 1) return -1;
else if(b == 2) return 0;
else if(b == 3) return 1;
else if(b == 4) return 0;
}else if(a == 2){
if(b == 0) return 0;
else if(b == 1) return 1;
else if(b == 2) return -1;
else if(b == 3) return 0;
else if(b == 4) return 1;
}else if(a == 3){
if(b == 0) return 0;
else if(b == 1) return 0;
else if(b == 2) return 1;
else if(b == 3) return -1;
else if(b == 4) return 1;
}else if(a == 4){
if(b == 0) return 1;
else if(b == 1) return 1;
else if(b == 2) return 0;
else if(b == 3) return 0;
else if(b == 4) return -1;
}
}

int main(){
int N,NA,NB,delta,ansA = 0,ansB = 0,j = 0,k = 0;scanf("%d %d %d",&N,&NA,&NB);
std::vector<int> A,B;
for(int i = 0;i < NA;i++) scanf("%d",&delta),A.push_back(delta);
for(int i = 0;i < NB;i++) scanf("%d",&delta),B.push_back(delta);
for(int i = 0;i < N;i++){
if(guess(A[j],B[k]) == 1) ansA++;
else if(guess(A[j],B[k]) == 0) ansB++;
j++,k++;
if(j >= NA) j = 0;
if(k >= NB) k = 0;
}

printf("%d %d",ansA,ansB);

return 0;
}
分享到