結果

問題 No.1243 約数加算
ユーザー AEnAEn
提出日時 2022-12-21 00:30:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 82,328 KB
実行使用メモリ 67,072 KB
最終ジャッジ日時 2024-04-29 03:03:54
合計ジャッジ時間 1,874 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,968 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 35 ms
52,096 KB
testcase_03 AC 35 ms
51,840 KB
testcase_04 AC 53 ms
65,024 KB
testcase_05 AC 55 ms
66,816 KB
testcase_06 AC 54 ms
67,072 KB
testcase_07 AC 54 ms
65,280 KB
testcase_08 AC 56 ms
66,816 KB
testcase_09 AC 35 ms
51,712 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