No.3088 XOR = SUM
タグ : / 解いたユーザー数 84
作問者 :
amentorimaru
Problem Statement
You are given a non-negative integer $N$. Construct one pair of integers $(X,Y)$ that satisfies the following conditions and maximizes $X\times Y$. (At least $1$ pair $(X,Y)$ satisfying the conditions exists.)
- $0\le X,Y$
- $X+Y\le N$
- $X \oplus Y = X + Y$
Here, $\oplus$ denotes the bitwise exclusive OR.
What is bitwise exclusive OR?
To compute $x \oplus y$, convert each of $x,y$ to binary and take the exclusive OR of each digit ($1$ if the values differ, $0$ if they are the same).
For example, $12\oplus 10 = 1100_{(2)} \oplus 1010_{(2)} = 0110_{(2)} = 6,\ \ 100 \oplus 100 = 0$.
Find the answer for all $T$ test cases.
Input
$T$ $case_1$ $case_2$ $\vdots$ $case_T$
Each test case is given in the following format.
$N$
Constraints
- $1\le T \le 2\times 10^5$
- $0\le N \le 10^{18} $
- All inputs are integers.
Output
Print $T$ lines. On the $i$-th line, print the answer for test case $i$. Any answer satisfying the conditions will be accepted.
Print a newline at the end.
Sample
Sample 1
Input
3 3 0 271828182845904
Output
2 1 0 0 140737488355328 131090694490576
For the first test case, $2\oplus 1 = 2+1=3$, and this maximizes $X\times Y$ among pairs $(X,Y)$ satisfying the conditions.
In addition, $(1,2)$ is also accepted as a correct answer.
Note that the given $N$ and the $X,Y$ to be printed may not fit in a $32$ bit integer type. (If you use C++, use long long instead of int.)
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。