Pseudoprime numbers(POJ 3641 快速幂)

 #include <cstring>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
#define LL long long
LL p,res,a;
bool judge_prime(LL k)
{
LL i;
LL u=int(sqrt(k*1.0));
for(i=;i<=u;i++)
{
if(k%i==)
return ;
}
return ;
}
int main()
{
freopen("in.txt","r",stdin);
while(scanf("%lld%lld",&p,&a))
{
if(p==&&a==)
break;
if(judge_prime(p))
{
printf("no\n");
continue;
}
res=;
LL t=p;
LL w=a;
while(p)
{
if(p&) res=(res*a)%t;
a=(a*a)%t;
p>>=;
}
if(res==w)
printf("yes\n");
else
printf("no\n");
}
}
上一篇:MiUI开发者版刷入xposed框架--简洁方法


下一篇:crtmpserver实现防盗流和流推送验证 之二