|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||64 MB||11||4||3||42.857%|
There is a rumor that the Scientific Committee is using a special device for encrypting their communication. If you can crack the encryption you could listen to the problems they have prepared and score many points. Last night you got lucky: one of the members forgot their device in a bar. You opened it and looked at the general design:
All the operations use 8 bits. XOR is the bitwise exclusive or function (the ^ operator in C, xor operator in Pascal).
R is a sequence of pseudorandom numbers defined as follows:
Furthermore, we have a function M, M:[0..255] →[0..255]. In fact, M is a bijection, i.e. when x≠y it must also be that M[x]≠M[y].
The device used by the Scientific Committee takes one number at a time, and outputs it encrypted.
After using the device N times, the next number, INPUT is encoded as follows:
Even though you understand how the encryption device works, you do not know the secret values R, R, and R. Also, you do not know M, so you cannot decode the communication. What you can do instead is play with the device you found. You can give it input numbers and observe the outputs.
Your task is to find out all the secret values: R, R, R, M, M, .., M with less than 320 queries (input numbers).
This is an interactive program. To play with the encryption module simply write a number between 0 and 255 to the standard output. You can then read from the standard input the output of the encryption device, also an integer between 0 and 255. When you know the secret values output one line containing the string SOLUTION and after that output 259 lines: R, R, R, M, M, …, M, one value per line.
Let's assume that R = 0, R = 1, R = 3 and that M[i] = (i + 1) MODULO 256. From here we deduce R = 1.
|Contestant output||Contestant input||Comments|
|10||11||M[10 XOR 0] = M = 11|
|10||12||M[10 XOR 1] = M = 12|
|11||9||M[11 XOR 3] = M = 9|
|12||14||M[12 XOR 1] = M = 14|
|When you find out the secret values you output them.|