結果

問題 No.1243 約数加算
ユーザー qumazakiqumazaki
提出日時 2020-10-03 02:02:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 895 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 76,900 KB
最終ジャッジ日時 2023-09-25 03:56:00
合計ジャッジ時間 3,450 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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)
            else:
                break
    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