結果

問題 No.3088 XOR = SUM
ユーザー SPD_9X2
提出日時 2025-04-04 22:07:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 721 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,888 KB
実行使用メモリ 77,304 KB
最終ジャッジ日時 2025-04-04 22:08:02
合計ジャッジ時間 16,895 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

110000000

100011111
 11111111



"""

import sys
from sys import stdin

TT = int(stdin.readline())

for loop in range(TT):

    N = int(stdin.readline())

    if N <= 10:
        ans = 0
        ans_tup = (0,0)
        for i in range(N+1):
            for j in range(N+1):
                if (i^j) == (i+j) and i*j > ans and i+j <= N:
                    ans = i*j
                    ans_tup = (i,j)

        print (*ans_tup)
        continue
    
    mb = 2**(N.bit_length()-1)
    ans = mb * (N - mb)
    ans_tup = (mb, N-mb)

    ooo = mb-1
    if ooo >= 3:
        mb2 = mb//2
        now = mb2 * (ooo-mb2)
        if now > ans:
            ans = now
            ans_tup = (mb2,ooo-mb2)

    print (*ans_tup)
0