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;
}
/**/

 

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-07 11:35
程序员小白条:话太多,没实力和学历,差不多回答回答就行了,身份地位不一样
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 15:58
点赞 评论 收藏
分享
下北澤大天使:你是我见过最美的牛客女孩😍
点赞 评论 收藏
分享
CARLJOSEPH...:宝宝你戾气太大了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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