結果

問題 No.1243 約数加算
ユーザー rlangevinrlangevin
提出日時 2023-03-21 18:28:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,012 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 72,128 KB
最終ジャッジ日時 2023-10-18 18:30:49
合計ジャッジ時間 4,285 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
14,548 KB
testcase_01 AC 28 ms
10,148 KB
testcase_02 AC 29 ms
10,148 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    A, B = map(int, input().split())
    ans = []
    nokori = 120
    while A != B:
        while 2 * A <= B:
            ans.append(A)
            A *= 2
            nokori -= 1
            
        if B - A <= nokori:
            ans.extend([1] * (B - A))
            break
                    
        ind = 1
        while A != B:
            # print(A, B, ans, sum(ans))
            two = 2 ** ind
            # if (B - A)//(two//2) <= nokori:
            #     ans.extend([two//2] * ((B - A)//(two//2) ))
            #     break
            if A % two == 0:
                if A + A // two <= B:
                    ans.append(A // two)
                    A += A // two
                    nokori -= 1
                    ind = 1
                    break
                else:
                    ind += 1
            else:
                A += two // 2
                nokori -= 1
                ans.append(two // 2)
            
    print(len(ans))
    print(*ans)
0