hdu1395

/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int n;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	while(scanf("%d", &n) == 1){
		if(n % 2 == 0){
			printf("2^? mod %d = 1\n", n);
		}else{
			int t = 1, flag = 0;
			for (int i = 1; i < 5000; i++){
				t *= 2;
				if(t % n == 1){
					printf("2^%d mod %d = 1\n", i, n);
					flag = 1;
					break;
				}else{
					t %= n;
				}
			}
			if(!flag){
				printf("2^? mod %d = 1\n", n);
			}
		}
	}

	return 0;
}
/**/

 

全部评论

相关推荐

牛客41406533...:回答他在课上学,一辈子待在学校的老教授用三十年前的祖传PPT一字一句的讲解,使用谭浩强红皮书作为教材在devc++里面敲出a+++++a的瞬间爆出114514个编译错误来学这样才显得专业
点赞 评论 收藏
分享
11-03 13:18
门头沟学院 Java
包行:平时怎么刷算法题的哇,字节的手撕听说都很难
字节跳动工作体验
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务