#7641. [VKOSHP 2025] System of Equations with XOR
[VKOSHP 2025] System of Equations with XOR
[VKOSHP 2025] System of Equations with XOR
题目描述
Alice and Bob love problems involving random numbers. One day they came up with the following problem:- First, Alice chooses a random integer from the range of to , all numbers are equally likely.
- Then, Bob chooses a random integer from the range of to , all numbers are equally likely.
- They calculate the product of these numbers and their bitwise XOR .
You are given two resulting integers and . Find any pair of natural numbers and such that:
where denotes the bitwise XOR operation.
Recall that the bitwise "exclusive or" (, xor) of two non-negative integers is defined as follows: write both numbers in binary representation; the -th binary digit of the result is 1 if exactly one of the arguments has it equal to 1. For example, ( xor ) = () = = .
输入格式
The first line of the input contains a single integer $t$ $(1 \leq t \leq 200\,000)$ --- the number of test cases.In the following lines of input, there are two integers and (, ) --- the description of the next test case.
输出格式
For each test case, output in a separate line two natural numbers $x$ and $y$, separated by a space, such that $xy = a$ and $x \oplus y = b$.If there are multiple valid answers, you may output any of them.
2
21 4
9 0
7 3
3 3