题目链接如下:
我的代码如下:
cpp
#include <cstdio>
#include <algorithm>
const int maxN = 1000;
int s[maxN], g[maxN], cntS[10], cntG[10];
int N, game, match, tot;
int main(){
game = 0;
while(scanf("%d", &N) && N){
std::fill(cntS, cntS + 10, 0);
for(int i = 0; i < N; ++i){
scanf("%d", &s[i]);
cntS[s[i]]++;
}
printf("Game %d:\n", ++game);
while(1){
std::fill(cntG, cntG + 10, 0);
match = 0;
for(int i = 0; i < N; ++i){
scanf("%d", &g[i]);
match += s[i] == g[i] ? 1 : 0;
cntG[g[i]]++;
}
if(!g[0]){
break;
}
tot = 0;
for(int i = 1; i < 10; ++i){
tot += std::min(cntS[i], cntG[i]);
}
printf(" (%d,%d)\n", match, tot - match);
}
}
return 0;
}