zoj1489-2^x mod n = 1
来源:互联网 发布:网络运营外包公司 编辑:程序博客网 时间:2024/04/28 12:41
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=489
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<bitset>using namespace std;int main(){int n ;while( cin >> n ){if( n % 2 == 0 || n < 2 ){cout << "2^? mod "<< n <<" = 1" << endl;continue ;}else{int temp = 0 ;int ans = 1 ;while( 1 ){ans *= 2 ;ans %= n ;temp++ ;if( ans % n == 1 )break ;}cout << "2^" << temp << " mod "<< n <<" = 1" << endl;}} return 0 ;}
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<bitset>using namespace std;int main(){int n ;while( cin >> n ){if( n % 2 == 0 || n < 2 ){cout << "2^? mod "<< n <<" = 1" << endl;continue ;}bool flag = false ;int sum = 1;for( int i = 1 ; ; ++i ){sum = 2 * sum ;if( sum % n == 1 ){cout << "2^" << i << " mod "<< n <<" = 1" << endl;flag = true ;break ;}sum %= n ;}if( !flag )cout << "2^? mod "<< n <<" = 1" << endl;;} return 0 ;}
- ZOJ1489 2^x mod n = 1
- zoj1489-2^x mod n = 1
- HDU1395 ZOJ1489 2^x mod n = 1【暴力法+数论】
- 2^x mod n = 1
- HDU1395:2^x mod n = 1
- hdu1395-2^x mod n = 1
- hdu1395 2^x mod n = 1
- 1073:2^x mod n = 1
- HDU1395---2^x mod n = 1
- HDU 2^x mod n = 1
- hdu1395 2^x mod n = 1
- HDU_1395 2^x mod n = 1
- 2^x mod n = 1
- hdoj1395 2^x mod n = 1
- hdu1395 2^x mod n = 1
- 1395 2^x mod n = 1
- hduoj1395(2^x mod n = 1)
- 2^x mod n = 1
- 【Java】字符串常用函数
- 摆花
- sicily 1035. DNA matching
- Trade
- Gist 介绍
- zoj1489-2^x mod n = 1
- sicily 1036. Crypto Columns
- Python对于文件的操作
- 如何在Eclipse中查看JDK类库的源代码
- sicily 1046. Plane Spotting
- C#中String的数据类型以及使用new时的对象分配情况
- Zoj 1076 Gene Assembly
- sicily 1049. Mondriaan
- Sql Server 2008修改sa登陆密码