Generator Dream
시간 제한1초메모리 제한2048 MB
소수 p와 x*2^(i-1) mod p의 하위 비트 ceil(log2 p)개가 주어질 때 비밀 시드 x를 복원한다.
문제
Rem is playing a game that relies on random bits and is starting to get annoyed by all the random chance. Rem wants to win, not to gamble! So, Rem wants your help in avoiding the randomness as much as possible.
The game generates randomness by starting with a secret seed and a known prime . Then the game generates a sequence of "random" numbers and "random" bits by defining
, and .
Rem has been playing for a while, and thinks they have enough information to guess the secret . Given and the first "random" bits, return the secret for Rem.
입력
Input consists of a prime number , () and a binary string as described above.
출력
Display the value of reduced modulo . That is, the value of the secret seed .