結果

問題 No.1331 Moving Penguin
ユーザー H3PO4H3PO4
提出日時 2022-03-19 09:12:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 691 ms / 1,500 ms
コード長 606 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 87,936 KB
最終ジャッジ日時 2024-04-25 05:21:43
合計ジャッジ時間 27,379 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
64,768 KB
testcase_01 AC 38 ms
51,712 KB
testcase_02 AC 36 ms
51,712 KB
testcase_03 AC 37 ms
51,840 KB
testcase_04 AC 661 ms
81,536 KB
testcase_05 AC 604 ms
78,848 KB
testcase_06 AC 607 ms
78,976 KB
testcase_07 AC 625 ms
78,976 KB
testcase_08 AC 624 ms
79,360 KB
testcase_09 AC 622 ms
79,104 KB
testcase_10 AC 614 ms
78,208 KB
testcase_11 AC 601 ms
78,464 KB
testcase_12 AC 600 ms
78,464 KB
testcase_13 AC 606 ms
78,464 KB
testcase_14 AC 612 ms
78,464 KB
testcase_15 AC 608 ms
78,720 KB
testcase_16 AC 599 ms
78,592 KB
testcase_17 AC 621 ms
79,232 KB
testcase_18 AC 626 ms
79,360 KB
testcase_19 AC 631 ms
79,232 KB
testcase_20 AC 599 ms
79,104 KB
testcase_21 AC 615 ms
79,232 KB
testcase_22 AC 601 ms
78,976 KB
testcase_23 AC 606 ms
78,336 KB
testcase_24 AC 605 ms
78,336 KB
testcase_25 AC 605 ms
78,208 KB
testcase_26 AC 629 ms
87,808 KB
testcase_27 AC 634 ms
87,936 KB
testcase_28 AC 642 ms
87,936 KB
testcase_29 AC 607 ms
80,384 KB
testcase_30 AC 169 ms
70,272 KB
testcase_31 AC 302 ms
76,800 KB
testcase_32 AC 146 ms
70,144 KB
testcase_33 AC 294 ms
73,344 KB
testcase_34 AC 365 ms
79,360 KB
testcase_35 AC 655 ms
87,296 KB
testcase_36 AC 662 ms
87,168 KB
testcase_37 AC 651 ms
87,168 KB
testcase_38 AC 180 ms
71,808 KB
testcase_39 AC 601 ms
87,680 KB
testcase_40 AC 267 ms
75,136 KB
testcase_41 AC 623 ms
80,128 KB
testcase_42 AC 668 ms
87,296 KB
testcase_43 AC 672 ms
87,168 KB
testcase_44 AC 659 ms
87,168 KB
testcase_45 AC 691 ms
87,168 KB
testcase_46 AC 691 ms
87,296 KB
testcase_47 AC 681 ms
87,424 KB
testcase_48 AC 605 ms
77,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def isqrt(n):
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x


N = int(input())
A = map(int, input().split())
sq = isqrt(N)
MOD = 10 ** 9 + 7

dp = [0] * N
dp[0] = 1

small_a = [[0] * i for i in range(sq)]

for i, a in enumerate(A):
    for b in range(1, sq):
        dp[i] += small_a[b][i % b]
    dp[i] %= MOD

    if i + 1 < N and a != 1:
        dp[i + 1] += dp[i]

    if sq <= a:
        for j in range(i + a, N, a):
            dp[j] += dp[i]
    else:
        small_a[a][i % a] += dp[i]
        small_a[a][i % a] %= MOD
print(dp[-1] % MOD)
0