HDOJ 2^x mod n = 1 1395
来源:互联网 发布:usb端口上的电涌不足 编辑:程序博客网 时间:2024/05/16 13:49
2^x mod n = 1
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13630 Accepted Submission(s): 4213
Problem Description
Give a number n, find the minimum x(x>0) that satisfies 2^x mod n = 1.
Input
One positive integer on each line, the value of n.
Output
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.
Print 2^? mod n = 1 otherwise.
You should replace x and n with specific numbers.
Sample Input
25
Sample Output
2^? mod 2 = 12^4 mod 5 = 1
Author
MA, Xiao
Source
ZOJ Monthly, February 2003
Recommend
Ignatius.L | We have carefully selected several similar problems for you: 2462 2421 2521 1695 2466
#include<stdio.h>int F_pow(int x,int n,int modn){int res=1;while(n){ if(n&1) res=res*x%modn; x=x*x%modn; n>>=1;} return res;}int main(){int F_pow(int x,int n,int modn);int n;while(scanf("%d",&n)!=EOF){int i=0;if(!(n&1)||n<=1){printf("2^? mod %d = 1\n",n);continue;}int num=0;for(i=1;;i++){num=F_pow(2,i,n);if(num==1) break;}printf("2^%d mod %d = 1\n",i,n);}return 0;}
0 0
- 【HDOJ】1395 -> 2^x mod n = 1
- 2^x mod n = 1 hdoj 1395
- hdoj.1395 2^x mod n = 1 20140725
- hdoj 1395 2^x mod n = 1 【暴力】
- HDOJ-1395-2^x mod n = 1 解题报告
- hdoj 1395 2^x mod n = 1
- HDOJ 2^x mod n = 1 1395
- HDOJ 1395 2^x mod n = 1
- HDOJ 1395 2^x mod n = 1
- hdoj 1359 2^x mod n = 1
- 1395 2^x mod n = 1
- HDU/HDOJ 1395 ACM浙大月赛 2^x mod n = 1
- HDOJ 题目1395 2^x mod n = 1(水题 易错)
- 2^x mod n = 1 【杭电-HDOJ-1395】 附题
- hdoj-1395-2^x mod n = 1【欧拉定理】
- HDOJ 1316 2^x mod n = 1
- 2^x mod n = 1
- ZOJ1489 2^x mod n = 1
- CSS盒子的定位
- 1.11
- apple icon and image size
- 1.12
- ACM 荣耀之路-学习方法
- HDOJ 2^x mod n = 1 1395
- C语言 编写一个函数,用递归方式求最大公约数。
- xampp安装应用
- cJSON源码解释(二)--解释输入
- 运行时错误检查(/RTC)编译选项及实现原理 .
- C++习题
- 【阅读自理】OC基础,各种NS
- CocoaPods 导入第三方库头文件自动补齐
- linux 下 android手机驱动解决办法