题解:CF2093C Simple Repetition
首先考虑
然后就是
所以展开可以知道就是
#include<bits/stdc++.h>
using namespace std;
struct FSI{
template<typename T>
FSI& operator >> (T &res){
res=0;T f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)){res=res*10+ch-'0';ch=getchar();}
res*=f;
return *this;
}
}scan;
int T,x,k,i;
bool isprime(int x)
{
int i;
if (x==1) return false;
for (i=2;i<=sqrt(x);i++)
{
if (x%i==0) return false;
}
return true;
}
void work()
{
scan>>x>>k;
if (x==1&&k==2){printf("YES\n");return;}
if (k!=1) printf("NO\n");
else
{
if (isprime(x)) printf("YES\n");
else printf("NO\n");
}
}
int main()
{
scan>>T;
while (T--) work();
return 0;
}