結果

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

ソースコード

diff #

T=int(input())
for _ in range(T):
    N=int(input())
    x,y=0,0
    first = True
    ans=0
    x_,y_=0,0
    for i in range(59,-1,-1):
        if first:
            if x+(1<<i)<=N:
                x+=(1<<i)
                first=False
        else:
            if (1>>i)+((1<<i)+1)<=N and ans<=(1<<i)*((1<<i)-1):
                ans=(1<<i)*((1<<i)-1)
                x_=(1<<i)
                y_=(1<<i)-1
            if x+y+(1<<i)<=N:
                y+=(1<<i)
    if ans<=x*y:
        ans=x*y
        x_=x
        y_=y
    assert x_^y_==x_+y_
    assert x_+y_<=N
    print(x_,y_)
    #print(x_*y_,140737488355328*131090694490576)

0