// http://acm.hdu.edu.cn/showproblem.php?pid=1395 #include<iostream> using namespace std; int main() { int n; while(scanf("%d",&n)!=EOF) { if(n==1 || n%2==0) // 这里的意思就是无论?是什么,n=1 只会是0,而没有余1的可能,n=2也是这样的意思 { printf("2^? mod %d = 1\n",n); } else { int mi=1,tmp=2; while(tmp!=1) // 利用枚举,数据少,可以直接AC的 { tmp=tmp*2%n; mi++; } printf("2^%d mod %d = 1\n",mi,n); } } system("pause"); return 0; }