結果

問題 No.1243 約数加算
ユーザー aqua_tenhouaqua_tenhou
提出日時 2020-10-02 21:58:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 7,924 KB
最終ジャッジ日時 2023-09-24 12:17:06
合計ジャッジ時間 1,722 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,772 KB
testcase_01 AC 16 ms
7,812 KB
testcase_02 AC 16 ms
7,768 KB
testcase_03 AC 17 ms
7,772 KB
testcase_04 AC 27 ms
7,900 KB
testcase_05 AC 53 ms
7,888 KB
testcase_06 AC 60 ms
7,836 KB
testcase_07 AC 31 ms
7,816 KB
testcase_08 AC 62 ms
7,924 KB
testcase_09 AC 18 ms
7,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(x):
    ret = 0
    while(x%2 == 0):
        ret += 1
        x = x//2
    return ret

t = int(input())
for _ in range(t):
    a,b = map(int,input().split())
    lis = []
    k = 0
    
    while (a != b):
        r = f(a)
        c = b-a
        if 2**r > c:
            while 2**r > c:
                r -= 1
        
        a += 2**r
        k += 1
        lis.append(2**r)
    print(k)
    for i in range(k):
        print(lis[i],end="")
        if i != k-1:
            print(" ",end="")
    print()
0