hdu 1905 Pseudoprime numbers
#include<stdio.h> #include<math.h> #define ll long long ll mod; bool Judge(int x) { for(int i=2;i<sqrt(x+0.1);i++) { if(x%i==0) return true; } return false; } ll mult(ll q,ll n) { ll ret=q; ll ans=1; while(n>0) { if(n&1) { ans*=ret; ans%=mod; } ret=(ret*ret)%mod; n>>=1; } return ans; } int main() { int p,a; while(scanf("%d %d",&p,&a)!=EOF) { if(p==0&&a==0)break; mod=p;// if(Judge(p)&&(int)mult(a,p)==a) printf("yes\n"); else printf("no\n"); //printf("%d %d\n",((int)pow(a,p))%p,a); } return 0; }