Files
python/TangDou/LuoGuBook/第8章模拟与高精度/P1328_1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

42 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 210;
//0 表示“剪刀”,1 表示“石头”,2 表示“布”,3 表示“蜥蜴人”,4表示“斯波克”。
//看图打表写出对阵双方的胜负平结果二维数组
//这个胜负平表是关键
int g[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}
};
int n; //表示进行N次猜拳
int n1; //小A出拳的周期长度
int n2; //小B出拳的周期长度
int na[N]; //表示小A出拳的规律
int nb[N]; //表示小B出拳的规律
int s1; //小A赢几次
int s2; //小B赢几次
int main() {
//数据读入
cin >> n >> n1 >> n2;
for (int i = 0; i < n1; i++)cin >> na[i];
for (int i = 0; i < n2; i++)cin >> nb[i];
//开始猜拳
for (int i = 0; i < n; i++) {
//这一轮小A出的是啥?
int a = na[i % n1]; //n1为循环的长度,所以每一轮后,都需要mod n1
//这一轮小B出的是啥?
int b = nb[i % n2]; //n2为循环的长度,所以每一轮后,都需要mod n2
s1 += g[a][b]; //根据事先推出的胜负平表,找出胜负平关系,累加到小A的得分中。
s2 += g[b][a]; //根据事先推出的胜负平表,找出胜负平关系,累加到小A的得分中。
}
cout << s1 << " " << s2 << endl;
return 0;
}