本来打算直接打表的,但看了看网上的解答觉得很有道理。
如果n m互质,那么狼总能遍历完所有的洞,相反,则狼总有遍历不到的洞。
#include <bits/stdc++.h>
using namespace std;
//本质上是求公因数问题,如果互质,那么狼转了很多圈后一定会遍历完所有的洞
int main()
{
int T;
cin >> T;
while(T--)
{
int m,n;
cin >> m >> n;
if(__gcd(m,n) == 1) cout << "NO\n";
else cout << "YES\n";
}
return 0;
}