UVA 10006 - Carmichael Numbers 快速幂

2014-11-24 10:25:45 · 作者: · 浏览: 0

题目大意:

我们把对任意的1

思路:

编译器暂时改为Dev c++ 原来是VS2012 ,为了适应过几周的蓝桥杯编译环境。

直接枚举x用上快速幂即可。

还有要注意的是合数,素数就不是Carmichael number啦。

#include
  
   
#include
   
     typedef long long LL; const int MAXN=65000+10; bool primer[MAXN]; LL pow(LL x,LL n,LL mod) //x^n%mod { LL res=1; while(n) { if( n & 1) res=res*x%mod; x=x*x%mod; n>>=1; } return res; } int main() { memset(primer,0,sizeof(primer)); for(int i=2;i*i