HDU1395+快速幂

 #include<stdio.h>
int fast_pow( int a,int b,int mod ){
int res = ;
while( b>= ){
if( b%== ){
res = res*a%mod;
}
a = a*a%mod;
b/=;
}
return res;
}
int main(){
int n;
while( ~scanf("%d",&n) ){
if( n==||n%== ){
printf("2^? mod %d = 1\n",n);
continue;
}
int ans = ;
while( ){
if( fast_pow( ,ans,n )== )
break;
ans++;
}
printf("2^%d mod %d = 1\n",ans,n);
}
return ;
}
上一篇:不停止MySQL服务的情况下修改root的密码


下一篇:sql, plsql 总结