Problem Statement  
You have two lists of numbers, X and Y, each containing exactly N elements. You can optionally apply any number of circular shifts to each list. A circular shift means removing the last element from a list and reinserting it before the first element. For example, {1, 2, 3} would become {3, 1, 2}, and {3, 1, 2} would become {2, 3, 1}. After you apply any circular shifts, the final score is calculated as: X[0]*Y[0] + X[1]*Y[1] + ... + X[N1]*Y[N1] You are given ints Z0, A, B and M. Generate a list Z of length 2*N, using the following recursive definition: Z[0] = Z0 MOD M Z[i] = (Z[i1]*A+B) MOD M (note that Z[i1]*A+B may overflow a 32bit integer) Then, generate lists X and Y, each of length N, using the following definitions: X[i] = Z[i] MOD 100 Y[i] = Z[i+N] MOD 100 Return the maximal final score you can achieve.  
Definition  
 
Notes  
  In the statement, "A MOD B" represents the remainder of integer division of A by B. For example, 14 MOD 5 = 4 and 20 MOD 4 = 0.  
  The author's solution does not depend on any properties of the pseudorandom generator. It would solve any input of allowed size within the given limits.  
Constraints  
  N will be between 1 and 60,000, inclusive.  
  Z0, A and B will each be between 0 and 1,000,000,000, inclusive.  
  M will be between 1 and 1,000,000,000, inclusive.  
Examples  
0)  
 
1)  
 
2)  
 
3)  
 
4)  
