結果

問題 No.1243 約数加算
ユーザー AEnAEn
提出日時 2022-12-21 00:30:42
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 749 ms
コンパイル使用メモリ 86,880 KB
実行使用メモリ 76,508 KB
最終ジャッジ日時 2023-08-11 10:32:32
合計ジャッジ時間 3,759 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,068 KB
testcase_01 AC 69 ms
70,984 KB
testcase_02 AC 69 ms
71,068 KB
testcase_03 AC 66 ms
71,048 KB
testcase_04 AC 99 ms
76,172 KB
testcase_05 AC 88 ms
76,484 KB
testcase_06 AC 88 ms
76,352 KB
testcase_07 AC 86 ms
76,468 KB
testcase_08 AC 90 ms
76,508 KB
testcase_09 AC 68 ms
71,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for i in range(T):
    A, B = map(int, input().split())
    a, b = A, B
    res = []
    p = 0
    while a!=b:
        if a&1:
            res.append(1<<p)
            a += 1
        p += 1
        a //= 2
        b //= 2
    A += sum(res)
    p2 = 1<<60
    while A!=B:
        if A+p2<=B:
            A += p2
            res.append(p2)
        p2 //= 2
    print(len(res))
    print(*res)
0