算法
这题直接打表就完了qwq
C++ 代码
#include <iostream>
using namespace std;
int main() {
int vs[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, na, nb;
cin >> n >> na >> nb;
int a[na], b[nb];
for (int i = 0; i < na; i++) {
cin >> a[i];
}
for (int i = 0; i < nb; i++) {
cin >> b[i];
}
int resa = 0, resb = 0;
for (int i = 0; i < n; i++) {
resa += vs[a[i % na]][b[i % nb]];
resb += vs[b[i % nb]][a[i % na]];
}
cout << resa << " " << resb << endl;
return 0;
}