没注释有空格
2025-05-19 20:46:40
发布于:广东
0阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, mod;
cin >> t >> mod;
while (t--) {
int x, y;
cin >> x >> y;
if (x == 0) {
cout << 1 << endl;
continue;
}
if (y == 0) {
cout << 2 << endl;
continue;
}
set<tuple<int, int, bool>> visited;
bool draw = false;
int temp = 1;
while (x != 0 && y != 0) {
if (visited.count({x, y, temp})) {
draw = true;
break;
}
visited.insert({x, y, temp});
if (temp) {
x = (x + y) % mod;
} else {
y = (x + y) % mod;
}
temp ^= 1;
}
if (draw) {
cout << "error" << endl;
} else {
cout << (x == 0 ? 1 : 2) << endl;
}
}
return 0;
}
这里空空如也
有帮助,赞一个