hdu 1395
2012-12-06 09:16
120 查看
2^x mod n = 1
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7368 Accepted Submission(s): 2221
[align=left]Problem Description[/align]
Give a number n, find the minimum x(x>0) that satisfies 2^x mod n = 1.
[align=left]Input[/align]
One positive integer on each line, the value of n.
[align=left]Output[/align]
If the minimum x exists, print a line with 2^x mod n = 1.
Print 2^? mod n = 1 otherwise.
You should replace x and n with specific numbers.
[align=left]Sample Input[/align]
2 5
[align=left]Sample Output[/align]
2^? mod 2 = 1 2^4 mod 5 = 1
[align=left]Author[/align]
MA, Xiao
[align=left]Source[/align]
ZOJ Monthly, February 2003
[align=left]Recommend[/align]
Ignatius.L
#include "stdio.h" int main() { int n, x, two; while(~scanf("%d",&n)) { if(n == 1 || n % 2 == 0){ printf("2^? mod %d = 1\n", n); continue; } x = 1, two = 2; while(two != 1) { two = two *2 % n; x++; } printf("2^%d mod %d = 1\n", x, n); } return 0; }
相关文章推荐
- hdu 1395 2^x mod n = 1
- HDU 1395 2^x mod n = 1
- hdu 1395 Minimum Transport Cost
- hdu 1395 2^x mod n = 1 暴力过~~最好学下欧拉定理~~~
- hdu 1395
- hdu 1395 2^x mod n = 1(欧拉函数)
- hdu1395 2^x mod n = 1
- SWUST ACM 训练题部分题解 hdu1384 && hdu3666 && hdu 4786 &&uva 1395 && uva 1151
- hdu 1395 Minimum Transport Cost
- hdu 1395 2^x mod n = 1
- hdu 1395 比较简单的数论题
- HDU-1395 2^x mod n = 1
- hdu 1395 2^x mod n = 1 欧拉定理(当然可以直接暴力)
- (step7.2.1)hdu 1395(2^x mod n = 1——简单数论)
- HDU 1395 2^x mod n = 1
- (step7.2.1)hdu 1395(2^x mod n = 1——简单数论)
- HDU 1395
- HDU1395+快速幂
- hdu 1395 2^x mod n = 1
- hdu 1395 2^x mod n = 1 (简单数论)