結果

問題 No.1243 約数加算
ユーザー ntudantuda
提出日時 2021-12-13 21:52:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 2,561 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 76,776 KB
最終ジャッジ日時 2023-09-30 03:23:32
合計ジャッジ時間 2,201 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,280 KB
testcase_01 AC 72 ms
71,368 KB
testcase_02 AC 71 ms
71,304 KB
testcase_03 AC 71 ms
71,372 KB
testcase_04 AC 99 ms
76,624 KB
testcase_05 AC 92 ms
76,504 KB
testcase_06 AC 96 ms
76,772 KB
testcase_07 AC 91 ms
76,776 KB
testcase_08 AC 93 ms
76,608 KB
testcase_09 AC 73 ms
71,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
AB = [list(map(int,input().split())) for _ in range(T)]

for a,b in AB:
    ans = []
    k = 0
    a2 = a
    a3 = a
    a4 = a
    while a2 % 2 == 0:
        k += 1
        a2 //= 2
    ad = pow(2,k)
    while b >= a + ad and a2 > 1:
        ans.append(ad)
        a += ad
        a2 += 1
        while a2 % 2 == 0:
            k += 1
            a2 //= 2
        ad = pow(2,k)
    while b >= 2 * a and a2 == 1:
        ans.append(a)
        a *= 2
        k += 1
    ad = pow(2,k)
    while b > a:
        if b >= a +ad:
            a += ad
            ans.append(ad)
        if k > 0:
            k -= 1
        ad = pow(2,k)
    print(len(ans))
    print(*ans)
0