問題一覧 > 通常問題

No.3088 XOR = SUM

レベル : / AI推定難易度 : 1225 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 84
作問者 : yuusaan / テスター : 👑 amentorimaru
お気に入りにしたユーザー ProblemId : 11822 / 自分の提出
問題文最終更新日: 2025-04-04 10:24:05
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 463 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。