题意:
思路:
1 #include<cstdio> 2 #include<cstdlib> 3 #include<algorithm> 4 #include<map> 5 #include<set> 6 #include<iostream> 7 #include<cstring> 8 typedef long long LL; 9 using namespace std; 10 11 int b,n,ans1,ans2,ans3,k; 12 13 int main() 14 { 15 freopen("bzoj1403.in","r",stdin); 16 freopen("bzoj1403.out","w",stdout); 17 for(int v=1;v<=100;v++) 18 { 19 scanf("%d%d",&b,&n); 20 ans1=0; ans2=0; ans3=0; 21 k=1; 22 for(int i=1;i<=1000;i++) 23 { 24 k=k*b%n; 25 if((!k)&&(!ans1)) ans1=i; 26 if((k==1)&&(!ans2)) ans2=i; 27 if((k==n-1)&&(!ans3)) ans3=i; 28 } 29 if(!(ans1+ans2+ans3)) printf("condition not found. "); 30 if(ans1) printf("Rightmost %d ",ans1); 31 if(ans2) printf("Add all %d ",ans2); 32 if(ans3) printf("Alternate %d change sign ",ans3); 33 34 printf(" "); 35 } 36 return 0; 37 }