CF1543D1.RPD and Rap Sheet (Easy Version)
普及+/提高
通过率:0%
时间限制:5.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is the easy version of the problem. The only difference is that here k=2. You can make hacks only if both the versions of the problem are solved.
This is an interactive problem.
Every decimal number has a base k equivalent. The individual digits of a base k number are called k-its. Let's define the k-itwise XOR of two k-its a and b as (a+b)modk.
The k-itwise XOR of two base k numbers is equal to the new number formed by taking the k-itwise XOR of their corresponding k-its. The k-itwise XOR of two decimal numbers a and b is denoted by a⊕kb and is equal to the decimal representation of the k-itwise XOR of the base k representations of a and b. All further numbers used in the statement below are in decimal unless specified. When k=2 (it is always true in this version), the k-itwise XOR is the same as the bitwise XOR.
You have hacked the criminal database of Rockport Police Department (RPD), also known as the Rap Sheet. But in order to access it, you require a password. You don't know it, but you are quite sure that it lies between 0 and n−1 inclusive. So, you have decided to guess it. Luckily, you can try at most n times without being blocked by the system. But the system is adaptive. Each time you make an incorrect guess, it changes the password. Specifically, if the password before the guess was x, and you guess a different number y, then the system changes the password to a number z such that x⊕kz=y. Guess the password and break into the system.
这是该问题的简单版本。唯一的区别是此处 k=2。仅当两个版本的问题均被解决时,你才可以进行 hack。
这是一个交互式问题。
每个十进制数都有其对应的 k 进制表示。k 进制数的各位数字被称为 k-its。我们定义两个 k-its a 和 b 的 k-itwise XOR 为 (a+b)modk。
两个 k 进制数的 k-itwise XOR 等于将它们对应位上的 k-its 分别进行 k-itwise XOR 后所形成的新 k 进制数。两个十进制数 a 和 b 的 k-itwise XOR 记作 a⊕kb,其值等于 a 与 b 的 k 进制表示逐位进行 k-itwise XOR 后所得结果的十进制表示。下文所述所有数字均为十进制,除非另有说明。当 k=2(本版本中恒成立)时,k-itwise XOR 即等同于按位异或(bitwise XOR)。
你已成功入侵罗克波特警察局(RPD,又称 Rap Sheet)的罪犯数据库。但要访问该数据库,你需要输入密码。你并不知道密码,但非常确信它在 0 到 n−1(含端点)之间。因此,你决定尝试猜测密码。幸运的是,你在被系统封锁前最多可尝试 n 次。但该系统具有自适应性:每次你猜错时,密码都会发生变化。具体而言,若猜之前密码为 x,而你猜了一个不同的数 y,则系统会将密码更改为某个数 z,使得 x⊕kz=y。请猜出密码并成功入侵系统。
输入格式
The first line of input contains a single integer t (1≤t≤10000) denoting the number of test cases. t test cases follow.
The first line of each test case contains two integers n (1≤n≤2⋅105) and k (k=2).
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105.
输入的第一行包含一个整数 t(1≤t≤10000),表示测试用例的数量。随后是 t 个测试用例。
每个测试用例的第一行包含两个整数 n(1≤n≤2⋅105)和 k(k=2)。
保证所有测试用例的 n 值之和不超过 2⋅105。
输入输出样例
输入#1
1 5 2 0 0 1
输出#1
3 4 5
说明/提示
In the example test case, the hidden password is 2.
The first query is 3. It is not equal to the current password. So, 0 is returned, and the password is changed to 1 since 2⊕21=3.
The second query is 4. It is not equal to the current password. So, 0 is returned, and the password is changed to 5 since 1⊕25=4.
The third query is 5. It is equal to the current password. So, 1 is returned, and the job is done.
Note that this initial password is taken just for the sake of explanation. When you submit, the interactor might behave differently because it is adaptive.
在示例测试用例中,隐藏的密码是 2。
第一次查询为 3。它不等于当前密码,因此返回 0,且密码被更改为 1,因为 2⊕21=3。
第二次查询为 4。它不等于当前密码,因此返回 0,且密码被更改为 5,因为 1⊕25=4。
第三次查询为 5。它等于当前密码,因此返回 1,任务完成。
注意:此处所取的初始密码仅为解释之用。当你提交时,交互器的行为可能不同,因为它是自适应的。
输入解题思路,AI测评打分。不知道怎么写?