一不小心就超时了。、
代码:
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
#define sf scanf
#define pf printf
#define INF 1<<29
#define lint __int64
#define clr(x) memset(x,0,sizeof(x))
#define Clr(x) memset(x,-1,sizeof(x))
int n;
int main(){
int n,i,j;
while(scanf("%d",&n)==1){
if(n%2==0||n==1) printf("2^? mod %d = 1\n",n);
else{
for(i=2,j=1;;i=(i%n)*2,j++){
if(i%n==1){
printf("2^%d mod %d = 1\n",j,n);
break;
}
}
}
}
return 0;
}