2 条题解
-
1
#include <bits/stdc++.h> using namespace std; const int N=1e7+10; const int INF=0x3f3f3f3f; bool check(int n,int a) { int z = n; while (n % a != 0) { z = n % a; n = a; a = z; } return z==1; } int main() { int t,n,a,z=0; cin>>t; while(t--) { cin>>n>>a; if(a==1 || check(n,a)){ cout<<"YES"<<endl; } else { cout<<"NO"<<endl; } } return 0; }
这道题要是死脑筋数组枚举必定超时,转变思维求最大公因数是否为1就可以了。
具体证明看老师,懒得打。。。
- 1
信息
- ID
- 2988
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 90
- 已通过
- 37
- 上传者