ASeDatAb
시간 제한10초메모리 제한1024 MB
값을 오른쪽으로 회전한 뒤 XOR하는 블랙박스와 상호작용해 300번 이내로 8비트 레코드를 모두 0으로 만든다.
문제
A research consortium has been looking for the best possible database for three years, but they are still having problems. The database stores values as records that hold -bit binary strings. Unfortunately, their implementation of the function to set the value of a record is flawed.
Each record of the database is an -bit binary string. The bits of the binary string are indexed from to from left to right. When an instruction to set a specific record to a new value is received, instead of setting the value to the database does the following:
- Choose an integer between and , inclusive, and let be like but rotated by to the right. That is, the -th bit of is the -th bit of .
- Replace the current value of the record with XOR . That is, the new value of the record has a as its -th bit if and only if the -th bits of and are different.
- Finally, return the number of bits that are in the new value to the user.
Luckily, it turns out that no matter what the initial value is or what rotation values the database chooses, it is always possible to reset the value of a record to have all bits be with no more than uses of this operation. Implement a program to interact with the database that does this.
제한
- .
- for all .