結果

問題 No.1581 Multiple Sequence
ユーザー Kiri8128Kiri8128
提出日時 2021-07-02 23:13:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 448 ms / 2,000 ms
コード長 744 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 87,732 KB
最終ジャッジ日時 2023-09-11 23:40:02
合計ジャッジ時間 9,001 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
72,288 KB
testcase_01 AC 75 ms
71,884 KB
testcase_02 AC 406 ms
86,576 KB
testcase_03 AC 410 ms
86,956 KB
testcase_04 AC 246 ms
81,780 KB
testcase_05 AC 424 ms
87,344 KB
testcase_06 AC 299 ms
83,440 KB
testcase_07 AC 249 ms
81,764 KB
testcase_08 AC 269 ms
82,744 KB
testcase_09 AC 403 ms
86,460 KB
testcase_10 AC 329 ms
84,616 KB
testcase_11 AC 209 ms
80,524 KB
testcase_12 AC 275 ms
82,720 KB
testcase_13 AC 123 ms
78,588 KB
testcase_14 AC 419 ms
87,012 KB
testcase_15 AC 350 ms
85,204 KB
testcase_16 AC 220 ms
80,872 KB
testcase_17 AC 448 ms
87,732 KB
testcase_18 AC 193 ms
80,732 KB
testcase_19 AC 391 ms
86,036 KB
testcase_20 AC 396 ms
86,488 KB
testcase_21 AC 417 ms
87,196 KB
testcase_22 AC 319 ms
84,124 KB
testcase_23 AC 448 ms
87,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primeFactor(N):
    i, n, ret, d, sq = 2, N, {}, 2, 99
    while i <= sq:
        k = 0
        while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
        if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
        if i < 4: i = i * 2 - 1
        else: i, d = i+d, d^6
    if n > 1: ret[n] = 1
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)

N = int(input())
X = [0] * (10 ** 5 + 1)
X[0] = X[1] = 1
for i in range(2, N + 1):
    a = 0
    for d in divisors(i):
        b = i // d - 1
        a += X[b]
    X[i] = a
print(X[N] % (10 ** 9 + 7))
0