标签:style class blog c code tar
1 //Accepted 228 KB 31 ms 2 #include <cstdio> 3 #include <cstring> 4 __int64 n; 5 void slove() 6 { 7 int ans; 8 __int64 m; 9 if (n%2==0 || n==1) 10 { 11 printf("2^? mod %I64d = 1\n",n); 12 return ; 13 } 14 m=1; 15 ans=0; 16 int flag=1; 17 while (flag) 18 { 19 ans++; 20 m=2*m%n; 21 if (m==1) flag=0; 22 } 23 printf("2^%d mod %I64d = 1\n",ans,n); 24 } 25 int main() 26 { 27 while (scanf("%I64d",&n)!=EOF) 28 { 29 slove(); 30 } 31 return 0; 32 }
hdu1395 2^x mod n = 1,布布扣,bubuko.com
标签:style class blog c code tar
原文地址:http://www.cnblogs.com/djingjing/p/3749327.html