提交时间:2024-07-17 10:38:54

运行 ID: 156357

#include<iostream> using namespace std; const bool r[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}}; const int N = 210; int a[N], b[N], n, na, nb, ai = -1, bi = -1, as = 0, bs = 0; int main(){ cin >> n >> na >> nb; for(int i = 0; i < na; i++){ cin >> a[i]; } for(int i = 0; i < nb; i++){ cin >> b[i]; } for(int i = 0; i < n; i++){ ai++; bi++; if(a[ai % na] == b[bi % nb]) continue; if(r[a[ai % na]][b[bi % nb]]){ as++; } else{ bs++; } } cout << as << ' ' << bs; return 0; }