传送门:https://www.luogu.org/problemnew/show/P1328#sub
这道题相信大家都会做(
除了下面贴的代码外,还有个比较聪明的办法就是手动打出vs[i][j]表示加分情况
#include<cstdio> using namespace std; int n,na,nb,suma,sumb; int a[205],b[205]; int main() { scanf("%d%d%d",&n,&na,&nb); for(int i = 0;i < na;i++) scanf("%d",&a[i]); for(int i = 0;i < nb;i++) scanf("%d",&b[i]); for(int i = 0;i < n;i++) { if(a[i%na] == 0 && b[i%nb] == 1) sumb++; else if(a[i%na] == 0 && b[i%nb] == 2) suma++; else if(a[i%na] == 0 && b[i%nb] == 3) suma++; else if(a[i%na] == 0 && b[i%nb] == 4) sumb++; else if(a[i%na] == 1 && b[i%nb] == 2) sumb++; else if(a[i%na] == 1 && b[i%nb] == 3) suma++; else if(a[i%na] == 1 && b[i%nb] == 4) sumb++; else if(a[i%na] == 2 && b[i%nb] == 3) sumb++; else if(a[i%na] == 2 && b[i%nb] == 4) suma++; else if(a[i%na] == 3 && b[i%nb] == 4) suma++; else if(a[i%na] == 1 && b[i%nb] == 0) suma++; else if(a[i%na] == 2 && b[i%nb] == 0) sumb++; else if(a[i%na] == 3 && b[i%nb] == 0) sumb++; else if(a[i%na] == 4 && b[i%nb] == 0) suma++; else if(a[i%na] == 2 && b[i%nb] == 1) suma++; else if(a[i%na] == 3 && b[i%nb] == 1) sumb++; else if(a[i%na] == 4 && b[i%nb] == 1) suma++; else if(a[i%na] == 3 && b[i%nb] == 2) suma++; else if(a[i%na] == 4 && b[i%nb] == 2) sumb++; else if(a[i%na] == 4 && b[i%nb] == 3) sumb++; } printf("%d %d",suma,sumb); return 0; }