結果

問題 No.1243 約数加算
ユーザー qumazakiqumazaki
提出日時 2020-10-03 01:53:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 855 bytes
コンパイル時間 1,455 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 81,448 KB
最終ジャッジ日時 2023-09-25 03:38:56
合計ジャッジ時間 7,128 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,388 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

t,*ab = map(int, read().split())

def calc(a,b):
    res = []
    r_bit = 0
    if(a^b < a):
        length = 0
        for i in range(60):
            if (1<<i) > b:
                length = i
                break
        for i in range(length-1,0,-1):
            if(a&b) >> i :
                a -= (1<<i)
                b -= (1<<i)
    while(a^b > a):
        if(a & (1 << r_bit)):
            res.append(1 << r_bit)
            a += (1 << r_bit)
        else:
            r_bit += 1
    res2 = []
    for i in range(60):
        if(b^(1<<i) < (1<<i)):
            break
        if (b>>i)&1 :
            res2.append(1<<i)
    res += res2[::-1]
    print(len(res))
    print(*res)

it = iter(ab)
for a,b in zip(it,it):
    calc(a,b)
0