用nsqrt(n)的时间复杂度就能过
//Dreaming of Freedom:https://codeforces.com/problemset/problem/1826/C #include <bits/stdc++.h> //#define int long long using namespace std; const int N=1e5+10,mod=1e9+7; string s; int n,t,a[N],f[N],res,num,ans,m; bool vis[N]; int main() { std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>t; while(t--){ cin>>n>>m; if(n>=2&&m>=n){ cout<<"NO"<<endl; continue; } if(!(n%2)&&m>=2){ cout<<"NO"<<endl; continue; } if(n>m){ bool f=false; for(int i=2;i<=n/i&&i<=m;++i){ if(n%i==0){ f=true; break; } } if(f){ cout <<"NO"<<endl; continue; } } cout<<"YES"<<endl; } return 0; }
标签:false,cout,int,Freedom,cin,Dreaming,贪心 From: https://www.cnblogs.com/o-Sakurajimamai-o/p/17498803.html