There is a set named "setA" which only has a number M. And we assign 0 to W initially.
Also, there are N operations which consists of 8 parameters and a ID number. The ith (1 - Based) operation's ID number is i.
Other 8 parameters are:
Fa Fc X L R A B C |
For each operation (example for ith operation), we should follow these steps.
0. Before the operation, we let F = (Fa * W + Fc) Mod i .
1. Find the number of “Good numbers”, we assume the result is Count.
Good number must satisfied three condition:
(1) The number P from the“setA”.
(2) The P's ID is equal or greater than F.
(3) L <= (P xor X) <= R (xor meas exclusive OR operation).
2. Output the Count and assign Count to W.
3. Insert (W * A + B) Mod C to "setA", the ID of (W * A + B) Mod C is equal to the operation's ID, which means the ID of ( W * A + B ) Mod C is i too.
Note_1: "setA" is not a unique set. (It contains same numbers probably)
Note_2: The ID of M is 0.
3 2 0 1 0 2 0 3 1 2 4 1 2 2 1 5 1 2 4 3 8 8 6 3 2 6 6 6 1 1 7 8 2 6 2 5 4 8 1 0 5 8 7 5 1 4 1 1 3 1 7 9 5 6 2 8 9 2 6 7 3 5 1 5 9 2 3 6 7 9 9 1 4 6 5 7 1 7 7
1 1 0 0 0 0 0 1 2
For the first test case. 2 0 The set is {0} initially. 1 0 2 0 3 1 2 4 F = (0 * 1 + 0) Mod 1 = 0. In this way, there is a good number 0, because 0’s ID is 0, and 0 xor 2 =0. So we output 1 and insert (1 * 1 + 2) mod 4 = 3 to the set. The set is {0, 3} now. 1 2 1 5 1 2 4 F = (1 * 1 + 2) Mod 2 = 1. In this way, there is a good number 3, becasue 3’s ID is 1, and 3 xor 2 = 1. So we output 1 and insert (1 * 1 + 2) mod 4 = 3 to the set. The set is {0 , 3 , 3} now.
Dshawn @BUAA