結果

問題 No.1243 約数加算
ユーザー tktk_snsntktk_snsn
提出日時 2020-10-02 22:59:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 633 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,756 KB
実行使用メモリ 8,368 KB
最終ジャッジ日時 2023-09-24 22:38:37
合計ジャッジ時間 1,989 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def calc(A, B):
    res = []
    while A + A <= B:
        res.append(A)
        A += A

    dif = B - A
    cnt = 0
    while A % 2 == 0:
        cnt += 1
        A >>= 1

    while dif:
        for i in reversed(range(cnt + 1)):
            val = 1 << i
            if dif >= val:
                dif -= val
                res.append(val)
                cnt = i + 1
                break
    print(len(res))
    print(*res, sep=" ")


T = int(input())
query = tuple(tuple(map(int, input().split())) for _ in range(T))
for a, b in query:
    calc(a, b)
0