結果

問題 No.1243 約数加算
ユーザー rlangevinrlangevin
提出日時 2023-03-21 18:27:13
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,024 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 516,360 KB
最終ジャッジ日時 2023-10-18 18:30:33
合計ジャッジ時間 4,990 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 MLE -
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(*ans)
             
            
    
0