| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
新手————#include<stdio.h>
#include<math.h>
long long q;
bool isis(int num)
{
int i;
int upper=sqrt(num);
for(i=2;i<=upper;i++)
{
if(num%i==0)
{
return false;
}
}return true;
}
long long pow4(long long aa,long long b)
{
long long r=1,base=aa;
while(b!=0)
{
if(b&1)
{
r%=q;
r*=base;
}
base=base*base%q;
b>>=1;
}
return r;
}
int main()
{
long long aa;
while(scanf("%lld%lld",&q,&aa)!=EOF)
{
if(q==0&&aa==0)break;
if(isis(q)){printf("no\n");continue;}
long long w=pow4(aa,q);
if(w%q==aa)printf("yes\n");
else printf("no\n");
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator