模拟即可
C++ 代码
#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;
const int N = 210;
int a[N], b[N];
int n, n1, n2;
int l, r;
int SF(int x1, int x2)
{
if (x1 == 0)
{
if (x2 == 0)
return 0;
if (x2 == 1)
return -1;
if (x2 == 2)
return 1;
if (x2 == 3)
return 1;
if (x2 == 4)
return -1;
}
if (x1 == 1)
{
if (x2 == 0)
return 1;
if (x2 == 1)
return 0;
if (x2 == 2)
return -1;
if (x2 == 3)
return 1;
if (x2 == 4)
return -1;
}
if (x1 == 2)
{
if (x2 == 0)
return -1;
if (x2 == 1)
return 1;
if (x2 == 2)
return 0;
if (x2 == 3)
return -1;
if (x2 == 4)
return 1;
}
if (x1 == 3)
{
if (x2 == 0)
return -1;
if (x2 == 1)
return -1;
if (x2 == 2)
return 1;
if (x2 == 3)
return 0;
if (x2 == 4)
return 1;
}
if (x1 == 4)
{
if (x2 == 0)
return 1;
if (x2 == 1)
return 1;
if (x2 == 2)
return -1;
if (x2 == 3)
return -1;
if (x2 == 4)
return 0;
}
}
int main()
{
ios::sync_with_stdio(0);
cin >> n >> n1 >> n2;
for (int i = 0; i <n1; i++)
{
cin >> a[i];
}
for (int j = 0; j <n2; j++)
{
cin >> b[j];
}
for (int i = 0; i <n; i++)
{
int x1 = i % n1;
int x2 = i % n2;
if (SF(a[x1], b[x2]) == 1)
{
l++;
}
else if (SF(a[x1], b[x2]) == 0)
{
l += 0;
}
else
r++;
}
cout << l << " " << r << endl;
}