更新时间:2022-08-22 22:36:49
1 2
120
1 2 #include <stdio.h> 3 #include <string.h> 4 int main() 5 { 6 int i,j,k,T; 7 int num; 8 int res = 1,step; 9 scanf("%d",&T); 10 int ans[1000]; 11 while(T--) 12 { 13 res = 1; 14 step = 0; 15 memset(ans,0,sizeof(ans)); 16 scanf("%d",&num); 17 while(res<1000) 18 { 19 step++; 20 res *= num; 21 } 22 num %= 1000; 23 res %= 1000; 24 ans[res] = step; 25 while(1) 26 { 27 res = res*num%1000; 28 step++; 29 if(ans[res]) 30 { 31 printf("%d\n",ans[res]+step); 32 break; 33 } 34 else 35 ans[res] = step; 36 } 37 } 38 return 0; 39 } 40 41 42 43