打个表模拟一下就好了。(似乎用0~n-1)会好写
?
AC代码如下:
#include<iostream>
#include<cstdio>
using namespace std;
int p[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,cnt1,cnt2,a[205],b[205];
int main(){
scanf("%d%d%d",&n,&cnt1,&cnt2); int i,ans1=0,ans2=0;
for (i=0; i<cnt1; i++) scanf("%d",&a[i]);
for (i=0; i<cnt2; i++) scanf("%d",&b[i]);
for (i=0; i<n; i++){
int x=a[i%cnt1],y=b[i%cnt2]; ans1+=p[x][y]; ans2+=p[y][x];
}
printf("%d %d\n",ans1,ans2);
return 0;
}
by lych
2015.12.22