結果

問題 No.1331 Moving Penguin
ユーザー tktk_snsntktk_snsn
提出日時 2022-05-01 03:32:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,352 ms / 1,500 ms
コード長 614 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 86,652 KB
実行使用メモリ 328,632 KB
最終ジャッジ日時 2023-09-12 18:26:06
合計ジャッジ時間 52,610 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
82,476 KB
testcase_01 AC 70 ms
71,600 KB
testcase_02 AC 70 ms
71,660 KB
testcase_03 AC 70 ms
71,132 KB
testcase_04 AC 1,313 ms
327,944 KB
testcase_05 AC 1,313 ms
327,960 KB
testcase_06 AC 1,230 ms
328,320 KB
testcase_07 AC 1,236 ms
328,276 KB
testcase_08 AC 1,231 ms
328,592 KB
testcase_09 AC 1,233 ms
328,316 KB
testcase_10 AC 1,214 ms
328,464 KB
testcase_11 AC 1,232 ms
328,068 KB
testcase_12 AC 1,221 ms
328,436 KB
testcase_13 AC 1,213 ms
328,216 KB
testcase_14 AC 1,233 ms
328,632 KB
testcase_15 AC 1,222 ms
328,592 KB
testcase_16 AC 1,244 ms
328,596 KB
testcase_17 AC 1,033 ms
328,464 KB
testcase_18 AC 1,065 ms
328,604 KB
testcase_19 AC 1,083 ms
328,464 KB
testcase_20 AC 1,057 ms
328,436 KB
testcase_21 AC 1,077 ms
328,612 KB
testcase_22 AC 1,057 ms
328,320 KB
testcase_23 AC 1,209 ms
328,460 KB
testcase_24 AC 1,207 ms
328,612 KB
testcase_25 AC 1,213 ms
328,492 KB
testcase_26 AC 1,305 ms
328,300 KB
testcase_27 AC 1,316 ms
327,988 KB
testcase_28 AC 1,352 ms
328,316 KB
testcase_29 AC 1,233 ms
328,260 KB
testcase_30 AC 307 ms
128,036 KB
testcase_31 AC 580 ms
190,304 KB
testcase_32 AC 263 ms
119,436 KB
testcase_33 AC 384 ms
154,984 KB
testcase_34 AC 725 ms
222,948 KB
testcase_35 AC 1,310 ms
328,344 KB
testcase_36 AC 1,305 ms
328,524 KB
testcase_37 AC 1,308 ms
328,460 KB
testcase_38 AC 318 ms
132,160 KB
testcase_39 AC 1,135 ms
315,876 KB
testcase_40 AC 437 ms
170,820 KB
testcase_41 AC 1,031 ms
327,968 KB
testcase_42 AC 1,313 ms
328,464 KB
testcase_43 AC 1,287 ms
328,516 KB
testcase_44 AC 1,321 ms
328,336 KB
testcase_45 AC 1,332 ms
328,436 KB
testcase_46 AC 1,352 ms
328,200 KB
testcase_47 AC 1,335 ms
328,584 KB
testcase_48 AC 1,220 ms
328,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))
sq = int(N ** 0.5) + 1

dp = [0] * (N + 1)
memo = [[0] * N for _ in range(sq+1)]
dp[0] = 1
for i in range(N):
    a = A[i]
    for j in range(1, sq + 1):
        if i - j >= 0:
            memo[j][i] += memo[j][i-j]
            memo[j][i] %= mod
        dp[i] += memo[j][i]
        dp[i] %= mod

    if a > sq:
        for j in range(i + a, N, a):
            dp[j] += dp[i]
            dp[j] %= mod
    else:
        memo[a][i] += dp[i]
        memo[a][i] %= mod

    if a > 1:
        dp[i+1] += dp[i]
        dp[i+1] %= mod

print(dp[N-1])
0