[题目链接]
[算法]
按题意模拟即可
[代码]
#include<bits/stdc++.h> using namespace std; #define MAXN 210 const int mat[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 i,Na,Nb,p,q,n,ans1,ans2; int a[MAXN],b[MAXN]; int main() { scanf("%d%d%d",&n,&Na,&Nb); for (i = 1; i <= Na; i++) scanf("%d",&a[i]); for (i = 1; i <= Nb; i++) scanf("%d",&b[i]); p = q = 1; for (i = 1; i <= n; i++) { ans1 += mat[a[p]][b[q]]; ans2 += mat[b[q]][a[p]]; p = p % Na + 1; q = q % Nb + 1; } printf("%d %d ",ans1,ans2); return 0; }