#include #include #include #include using namespace std; typedef unsigned __int64 u64; const int MAX=100; u64 f0[100],f1[100],ff,n,tmp,ret,ret1,p,pp; u64 myrandom() { u64 a; a=rand(); a*=rand(); a*=rand(); a*=rand(); return a; } u64 mulmod(u64 a,u64 b,u64 c) { u64 ret=0; while(b) { if(b&1) { ret+=a; if(ret>c) ret-=c; } a<<=1; if(a>c) a-=c; b>>=1; } return ret; } u64 powmod(u64 a,u64 b,u64 c) { u64 ret=1; while(b) { if(b&1) ret=mulmod(ret,a,c); a=mulmod(a,a,c); b>>=1; } return ret; } int miller(u64 base,u64 n) { u64 m=n-1,k=0; while(m%2==0) { m>>=1; k++; } if(powmod(base,m,n)==1) return 1; for(int i=0;i1) { if(Miller_Rabin(n)) break; tmp=Prime(n); f0[ff]=tmp; f1[ff]=1; n/=tmp; while(n%tmp==0) { n/=tmp; f1[ff]++; } ff++; } if(n>0) { f0[ff]=n; f1[ff++]=1; } for(int i=0;i