话不多说
AC代码
#include<iostream>
#include<queue>
using namespace std;
int suma,sumb;
int a[205],b[205],vis[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 main(){
int n,na,nb;
cin>>n>>na>>nb;
for(int i=0;i<na;i++){
cin>>a[i];
}
for(int i=0;i<nb;i++){
cin>>b[i];
}
for(int i=0;i<n;i++){
suma+=vis[a[i%na]][b[i%nb]];
sumb+=vis[b[i%nb]][a[i%na]];
}
cout<<suma<<" "<<sumb;
return 0;
}