結果

問題 No.3088 XOR = SUM
ユーザー nonon
提出日時 2025-04-04 21:59:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,019 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 674 ms
コンパイル使用メモリ 82,704 KB
実行使用メモリ 77,184 KB
最終ジャッジ日時 2025-04-04 22:00:35
合計ジャッジ時間 30,602 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(N):
    x, y = 0, 0
    for i in range(60, -1, -1):
        if (N >> i) & 1:
            if x == 0:
                x += 1 << i
            else:
                y += 1 << i
    return x, y


for _ in range(int(input())):
    N = int(input())
    x, y = solve(N)
    M = 0
    while 2 * M + 1 <= N:
        M = 2 * M + 1
    a, b = solve(M)
    if x * y >= a * b:
        print(x, y)
    else:
        print(a, b)
0