因为是两个人,而且最后一定会把能拿的数全部拿完。所以我们只需要讨论能拿的数sum有多少个即可。
- 如果a,b两个数不互质,即他们的最大公因数g大于1,那么在
范围内,所有满足的
的数都会被拿走。
- 如果a,b两个数互质,即他们的最大公因数g等于1,那么在
范围内,所有的数都会被拿走。
所以我们知道sum=n/gcd(a,b),因为只有两人,且谁完成最后一次操作时,谁获胜。所以sum偶数时张老师必输,奇数时张老师必胜。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const ll mod = 1e9 + 7;
inline ll read() {
ll s = 0, f = 1;
char ch;
do {
ch = getchar();
if (ch == '-') f = -1;
} while (ch < 48 || ch > 57);
while (ch >= 48 && ch <= 57)
s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
return s * f;
}
int main() {
ll t = read();
while (t--) {
ll n = read(), a = read(), b = read();
n /= __gcd(a, b);
if (n & 1) puts("Yes");
else puts("No");
}
return 0;
} 
京公网安备 11010502036488号