File size: 1,842 Bytes
df6dd12 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<p>You recently befriended a guy who writes software for slot machines. After hanging out with him a bit, you notice that he has a penchant for showing off his knowledge of how the slot machines work. Eventually you get him to describe for you in precise detail the algorithm used on a particular brand of machine. The algorithm is as follows:</p>
<pre>
int getRandomNumber() {
secret = (secret * 5402147 + 54321) % 10000001;
return secret % 1000;
}
</pre>
<p>This function returns an integer number in [0, 999]; each digit represents one of ten symbols that appear on a wheel during a particular machine state. <strong>secret</strong> is initially set to some nonnegative value unknown to you.</p>
<p>By observing the operation of a machine long enough, you can determine value of <b>secret</b> and thus predict future outcomes. Knowing future outcomes you would be able to bet in a smart way and win lots of money.</p>
<h2>
Input
</h2>
<p>The first line of the input contains positive number <strong>T</strong>, the number of test cases. This is followed by <strong>T</strong> test cases. Each test case consists of a positive integer <strong>N</strong>, the number of observations you make. Next <strong>N</strong> tokens are integers from 0 to 999 describing your observations.</p>
<h2>
Output
</h2>
<p>
For each test case, output the next 10 values that would be displayed by the machine separated by whitespace.<br/>
If the sequence you observed cannot be produced by the machine your friend described to you, print "Wrong machine" instead.<br/>
If you cannot uniquely determine the next 10 values, print "Not enough observations" instead.
</p>
<h2>
Constraints
</h2>
<strong>T</strong> = 20<br/>
1 ≤ <strong>N</strong> ≤ 100<br/>
Tokens in the input are no more than 3 characters long and contain only digits 0-9.
|