Given N consecutive terms of a sequence built from unknown coefficients over GF(10007), find the next term or print UNKNOWN.
Medium7MathNumber theoryBrute forceNo attempts yetTime limit5sMemory limit512 MBYou want the next number in a sequence S that a secret code generated. The code built the sequence by this procedure.
First, for each k from 0 to 29, pick a number Ck between 0 and 10006, inclusive.
Then, for each integer n from 0 to 109, inclusive:
You are given several consecutive values of S. You do not know where in the sequence your numbers begin, although you do know that at least one more number follows them, and you do not know which values of Ck were chosen.
Find the next number in the sequence. If the input data cannot determine it, print UNKNOWN.
The first line contains an integer T, the number of test cases.
Each test case takes two lines.
Limits
For each test case, print one line containing "Case #X: Y", where X is the test case number starting from 1 and Y is the next number in the sequence. If the next number cannot be determined, write UNKNOWN in place of Y.
In the first sample case, C0, C1 and C2 might have been 1, 2 and 4, with the given values starting at n=1. If that is what happened, C3 is unknown, so the next number could be anything, and the answer is UNKNOWN.
In the second sample case you cannot recover every value of Ck, and you cannot tell what n is either. Even so, in any sequence produced this way, if 1, 10, 11, 200 occur in this order, the next value is always 201.