题目(14)答案
#include <iostream>
#include <cstdio>
using namespace std;
int check(int a,int b)
{
//0石头,2剪刀,3布
if (a == 0 && b == 2)
return 1;
else if (a == 0 && b == 5)
return 2;
else if (a == 2 && b == 0)
return 2;
else if (a == 2 && b == 5)
return 1;
else if (a == 5 && b == 0)
return 1;
else if (a == 5 && b == 2)
return 2;
else
return 0;
}
int main()
{
int N, AN, BN;
//indent guides
//claudiaIDE
/*N轮数,AN是A规律数,BN是B规律数
10 3 4
0 2 5
0 5 0 2*/
int a[101] = { 0 }, b[101] = { 0 };
std::cin >> N;
std::cin >> AN;
std::cin >> BN;
int indexA = 0;
int indexB = 0;
//A的规律
for (int i = 0; i < AN; i++)
cin >> a[i];
//B的规律
for (int i = 0; i < BN; i++)
cin >> b[i];
int ai = 0; int bi = 0;
for (int i = 0; i < N; i++)
{
int x = check(a[ai], b[bi]);
//cout << "i=" << i << " " << "x=" << x << endl;
if (x == 1)
indexA++;
else if (x == 2)
indexB++;
//cout << "indexA=" << indexA << " " << "indexB=" << indexB << endl;
//cout << "ai=" << ai << " " << "bi=" << bi << endl;
ai++; bi++;
if (ai == AN)
ai = 0;
if (bi == BN)
bi = 0;
}
//char ans = indexA > indexB ? 'A' : 'B';
char ans;
if (indexA > indexB)
ans = 'A';
else
ans = 'B';
//cout << "A:" << indexA << " B:" << indexB << endl;
cout << ans << endl;
return 0;
}
没有任何难点。