結果

問題 No.1331 Moving Penguin
ユーザー tktk_snsntktk_snsn
提出日時 2022-05-01 03:34:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 389 ms / 1,500 ms
コード長 631 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 152,064 KB
最終ジャッジ日時 2024-04-25 05:21:59
合計ジャッジ時間 14,914 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
72,064 KB
testcase_01 AC 37 ms
52,352 KB
testcase_02 AC 37 ms
52,480 KB
testcase_03 AC 38 ms
52,352 KB
testcase_04 AC 290 ms
150,528 KB
testcase_05 AC 372 ms
151,296 KB
testcase_06 AC 368 ms
151,296 KB
testcase_07 AC 371 ms
151,040 KB
testcase_08 AC 276 ms
148,608 KB
testcase_09 AC 272 ms
148,480 KB
testcase_10 AC 277 ms
148,480 KB
testcase_11 AC 273 ms
148,224 KB
testcase_12 AC 275 ms
148,480 KB
testcase_13 AC 282 ms
148,352 KB
testcase_14 AC 283 ms
148,480 KB
testcase_15 AC 284 ms
148,608 KB
testcase_16 AC 282 ms
148,608 KB
testcase_17 AC 250 ms
151,168 KB
testcase_18 AC 253 ms
150,784 KB
testcase_19 AC 267 ms
150,912 KB
testcase_20 AC 261 ms
150,784 KB
testcase_21 AC 253 ms
151,040 KB
testcase_22 AC 257 ms
150,912 KB
testcase_23 AC 274 ms
148,352 KB
testcase_24 AC 278 ms
148,608 KB
testcase_25 AC 276 ms
148,224 KB
testcase_26 AC 310 ms
152,064 KB
testcase_27 AC 317 ms
151,936 KB
testcase_28 AC 307 ms
152,064 KB
testcase_29 AC 280 ms
150,912 KB
testcase_30 AC 156 ms
95,744 KB
testcase_31 AC 206 ms
118,144 KB
testcase_32 AC 135 ms
92,032 KB
testcase_33 AC 172 ms
105,344 KB
testcase_34 AC 229 ms
126,464 KB
testcase_35 AC 379 ms
151,424 KB
testcase_36 AC 374 ms
151,552 KB
testcase_37 AC 376 ms
151,424 KB
testcase_38 AC 153 ms
97,152 KB
testcase_39 AC 298 ms
149,888 KB
testcase_40 AC 181 ms
111,232 KB
testcase_41 AC 354 ms
151,424 KB
testcase_42 AC 389 ms
151,424 KB
testcase_43 AC 375 ms
151,552 KB
testcase_44 AC 372 ms
151,296 KB
testcase_45 AC 373 ms
151,552 KB
testcase_46 AC 385 ms
151,424 KB
testcase_47 AC 379 ms
151,680 KB
testcase_48 AC 273 ms
147,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7

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

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