What should I say about this question... Simple, simple, simple, and enumeration simulation. I started to get stuck for a long time. Today I saw that this question was not written again by question a. The code that seems to have timed out is handed in to question, practice is the only criterion for testing truth...
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 using namespace std; 5 6 const int mod = 10001 ; 7 8 int main (){ 9 int x[50005];10 int n;11 while (~scanf ("%d",&n)){12 for (int i=1;i<2*n;i+=2)13 scanf ("%d",&x[i]);14 int a,b;15 int flag;16 for (a=0;a<=10000;a++){17 for (b=0;b<=10000;b++){18 int temp;19 temp=(a*x[1]+b)%mod;20 temp=(a*temp+b)%mod;21 if (temp==x[3])22 break ;23 }24 //b=(x[3]-((a*a)%mod)*x[1]%mod)%mod/(a%mod+1);25 flag=0;26 for (int i=2;i<=2*n;i++){27 int temp=(a*x[i-1]+b)%mod;28 if (i%2&&temp!=x[i]){29 flag=1;30 break ;31 }32 x[i]=temp;33 }34 if (!flag)35 break ;36 }37 for (int i=2;i<=2*n;i+=2)38 printf ("%d\n",x[i]);39 }40 return 0;41 }
Ultraviolet A 12169 disgruntled judge