結果

問題 No.1243 約数加算
ユーザー ntudantuda
提出日時 2021-09-16 22:17:54
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 692 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 87,348 KB
実行使用メモリ 175,076 KB
最終ジャッジ日時 2023-09-12 04:15:15
合計ジャッジ時間 4,523 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
80,488 KB
testcase_01 AC 85 ms
76,636 KB
testcase_02 AC 90 ms
77,232 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    divisors.sort()
    return divisors

T = int(input())
AB = [list(map(int,input().split())) for _ in range(T)]

for a,b in AB:
    Q1 = {a:[]}
    Q2 = {}
    S1 = {}
    i = 0
    while not(b in Q1.keys()) and i < 120:
        for q,L in Q1.items():
            D = make_divisors(q)
            for d in D:
                qt = q + d
                if not(qt in Q2.keys()):
                    Q2[qt] = L + [d]
        Q1,Q2 = Q2,Q1
        i += 1
    print(len(Q1[b]))
    print(*Q1[b])
0