decimal number has a base k same. The singular digits of a base k number are called k-its. How about we characterize the k-itwise XOR of two k-its an and b as (a+b)modk. The k-itwise XOR of two base k numbers is equivalent to the new number framed by taking the k-itwise XOR of their relating k-its. The k-itwise XOR of two decimal
Correct answer will be upvoted else downvoted.
Each decimal number has a base k same. The singular digits of a base k number are called k-its. How about we characterize the k-itwise XOR of two k-its an and b as (a+b)modk.
The k-itwise XOR of two base k numbers is equivalent to the new number framed by taking the k-itwise XOR of their relating k-its. The k-itwise XOR of two decimal numbers an and b is signified by a⊕kb and is equivalent to the decimal portrayal of the k-itwise XOR of the base k portrayals of an and b. All further numbers utilized in the assertion underneath are in decimal except if indicated. When k=2 (it is in every case valid in this form), the k-itwise XOR is as old as bitwise XOR.
You have hacked the criminal data set of Rockport Police Department (RPD), otherwise called the Rap Sheet. However, to get to it, you require a secret word. You don't have any acquaintance with it, yet you are very certain that it lies somewhere in the range of 0 and n−1 comprehensive. In this way, you have chosen to get it. Fortunately, you can attempt all things considered n times without being impeded by the system. Yet, the system is versatile. Each time you make an erroneous supposition, it changes the secret phrase. In particular, if the secret key before the speculation was x, and you surmise an alternate number y, then, at that point, the system changes the secret phrase to a number z to such an extent that x⊕kz=y. Supposition the secret phrase and break into the system.
Input
The principal line of input contains a solitary integer t (1≤t≤10000) meaning the number of experiments. t experiments follow.
The primary line of each experiment contains two integers n (1≤n≤2⋅105) and k (k=2).
It is ensured that the amount of n over all experiments doesn't surpass 2⋅105.
Association
For each experiment, first read two integers n and k. Then, at that point, you might ask up to n questions.
For each question, print a solitary integer y (0≤y≤2⋅107). Leave the current secret phrase alone x. From that point onward, read an integer r.
In the event that x=y, you will peruse r=1 and the experiment is tackled. You should then keep addressing the excess experiments.
Else, you will peruse r=0. As of now the secret phrase is changed to a number z with the end goal that x⊕kz=y.
Subsequent to printing a question, remember to output the finish of line and flush the output. If not, you will get as far as possible surpassed decision.
Step by step
Solved in 3 steps with 1 images