集训总结---第一天:
字典树《《
286 290,511,163,685.
欧拉回路《《
HDOJ---1395
F - 2^x mod n = 1.
Time Limit:1000MS
IO Format:%I64d & %I64u
Give a number n, find the minimumx(x>0) that satisfies 2^x mod n = 1.
Input.
One positive integer on each line, thevalue of n.
Output.
If the minimum x exists, print a line with2^x mod n = 1.
Print 2^? mod n = 1 otherwise.
You should replace x and n with specific numbers.
Sample Input
5
Sample Output
2^4 mod 5 = 1
考点:
大数枚举。
#include<cstdio> #include<cstring> int main() { int T; while(scanf("%d",&T)!=EOF) { int i,nib = 2; bool flag = 0; for(i = 1;i<=T;i++) { nib = nib%T; if(nib==1) { flag = 1; break; } nib*=2; } if(flag) printf("2^%d mod %d = 1\n",i,T); else printf("2^? mod %d = 1\n",T); } return 0; }