思路如下
方法一:if else 直接模拟
方法二:初始化一个二维数组 输和平记为0,赢记为1 直接索引
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
#include <sstream>
#define inf 0x3f3f3f3f
#define eps 1e-6
using namespace std;
#define clr(x) memset(x,0,sizeof((x)))
const int maxn = 10000;
#define MAX(a,b,c) ((a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c)))
#define _max(a,b) ((a) > (b) ? (a) : (b))
#define _min(a,b) ((a) < (b) ? (a) : (b))
#define _for(a,b,c) for(int a = b;a<c;a++)
int r1,r2;
int arr[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}
};
void func(int x,int y) {
r1+=arr[x][y];
r2+=arr[y][x];
}
int main()
{
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif
int n,na,nb;
cin>>n>>na>>nb;
int a[205],b[205];
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(int i = 0;i<na;i++) {
cin>>a[i];
}
for(int j = 0;j<nb;j++) {
cin>>b[j];
}
for(int i = 0;i<n;i++) {
func(a[i%na],b[i%nb]);
}
cout<<r1<<" "<<r2;
return 0;
}