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=2k=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 kk equivalent. The individual digits of a base kk number are called kk-its. Let's define the kk-itwise XOR of two kk-its aa and bb as (a+b) mod k(a + b)\bmod k.

The kk-itwise XOR of two base kk numbers is equal to the new number formed by taking the kk-itwise XOR of their corresponding kk-its. The kk-itwise XOR of two decimal numbers aa and bb is denoted by a⊕kba\oplus_{k} b and is equal to the decimal representation of the kk-itwise XOR of the base kk representations of aa and bb. All further numbers used in the statement below are in decimal unless specified. When k=2k = 2 (it is always true in this version), the kk-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 00 and n−1n-1 inclusive. So, you have decided to guess it. Luckily, you can try at most nn 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 xx, and you guess a different number yy, then the system changes the password to a number zz such that x⊕kz=yx\oplus_{k} z=y. Guess the password and break into the system.

这是该问题的简单版本。唯一的区别是此处 k=2k=2。仅当两个版本的问题均被解决时,你才可以进行 hack。

这是一个交互式问题。

每个十进制数都有其对应的 kk 进制表示。kk 进制数的各位数字被称为 kk-its。我们定义两个 kk-its aa 和 bb 的 kk-itwise XOR 为 (a+b) mod k(a + b)\bmod k。

两个 kk 进制数的 kk-itwise XOR 等于将它们对应位上的 kk-its 分别进行 kk-itwise XOR 后所形成的新 kk 进制数。两个十进制数 aa 和 bb 的 kk-itwise XOR 记作 a⊕kba\oplus_{k} b,其值等于 aa 与 bb 的 kk 进制表示逐位进行 kk-itwise XOR 后所得结果的十进制表示。下文所述所有数字均为十进制,除非另有说明。当 k=2k = 2(本版本中恒成立)时,kk-itwise XOR 即等同于按位异或(bitwise XOR)。

你已成功入侵罗克波特警察局(RPD,又称 Rap Sheet)的罪犯数据库。但要访问该数据库,你需要输入密码。你并不知道密码,但非常确信它在 00 到 n−1n-1(含端点)之间。因此,你决定尝试猜测密码。幸运的是,你在被系统封锁前最多可尝试 nn 次。但该系统具有自适应性:每次你猜错时,密码都会发生变化。具体而言,若猜之前密码为 xx,而你猜了一个不同的数 yy,则系统会将密码更改为某个数 zz,使得 x⊕kz=yx\oplus_{k} z=y。请猜出密码并成功入侵系统。

输入格式

The first line of input contains a single integer tt (1≤t≤10 0001\leq t\leq 10\,000) denoting the number of test cases. tt test cases follow.

The first line of each test case contains two integers nn (1≤n≤2⋅1051\leq n\leq 2\cdot 10^5) and kk (k=2k=2).

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052\cdot 10^5.

输入的第一行包含一个整数 tt(1≤t≤10 0001\leq t\leq 10\,000),表示测试用例的数量。随后是 tt 个测试用例。

每个测试用例的第一行包含两个整数 nn(1≤n≤2⋅1051\leq n\leq 2\cdot 10^5)和 kk(k=2k=2)。

保证所有测试用例的 nn 值之和不超过 2⋅1052\cdot 10^5。

输入输出样例

  • 输入#1

    1
    5 2
    
    0
    
    0
    
    1

    输出#1

    3
    
    4
    
    5

说明/提示

In the example test case, the hidden password is 22.

The first query is 33. It is not equal to the current password. So, 00 is returned, and the password is changed to 11 since 2⊕21=32\oplus_2 1=3.

The second query is 44. It is not equal to the current password. So, 00 is returned, and the password is changed to 55 since 1⊕25=41\oplus_2 5=4.

The third query is 55. It is equal to the current password. So, 11 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.

在示例测试用例中,隐藏的密码是 22。

第一次查询为 33。它不等于当前密码,因此返回 00,且密码被更改为 11,因为 2⊕21=32\oplus_2 1=3。

第二次查询为 44。它不等于当前密码,因此返回 00,且密码被更改为 55,因为 1⊕25=41\oplus_2 5=4。

第三次查询为 55。它等于当前密码,因此返回 11,任务完成。

注意:此处所取的初始密码仅为解释之用。当你提交时,交互器的行为可能不同,因为它是自适应的。

输入解题思路,AI测评打分。不知道怎么写?

首页