結果

問題 No.1243 約数加算
ユーザー strangerxxxstrangerxxx
提出日時 2020-10-02 21:52:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 58,336 KB
最終ジャッジ日時 2023-09-23 04:48:52
合計ジャッジ時間 5,979 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def make_divisors(n: int):
    lower_divisors, upper_divisors = [], []
    i = 1
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
    return lower_divisors + upper_divisors[::-1]


def resolve():
    from bisect import bisect_left
    t = int(input())
    for _ in range(t):
        a, b = map(int, input().split())
        b -= a
        l = make_divisors(a)
        ans = []
        while b > 0:
            x = bisect_left(l, b + 1) - 1
            ans.append(l[x])
            b -= l[x]
        print(len(ans))
        print(*ans)


if __name__ == '__main__':
    resolve()
0