結果

問題 No.1331 Moving Penguin
ユーザー marroncastlemarroncastle
提出日時 2021-01-20 21:22:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 348 ms / 1,500 ms
コード長 529 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 90,752 KB
最終ジャッジ日時 2024-04-25 05:16:09
合計ジャッジ時間 11,318 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
67,200 KB
testcase_01 AC 43 ms
51,968 KB
testcase_02 AC 41 ms
52,096 KB
testcase_03 AC 42 ms
52,096 KB
testcase_04 AC 181 ms
90,752 KB
testcase_05 AC 348 ms
89,600 KB
testcase_06 AC 326 ms
89,600 KB
testcase_07 AC 347 ms
89,600 KB
testcase_08 AC 207 ms
85,504 KB
testcase_09 AC 200 ms
85,760 KB
testcase_10 AC 203 ms
85,504 KB
testcase_11 AC 202 ms
85,504 KB
testcase_12 AC 200 ms
85,888 KB
testcase_13 AC 203 ms
85,632 KB
testcase_14 AC 203 ms
85,632 KB
testcase_15 AC 203 ms
85,888 KB
testcase_16 AC 204 ms
85,632 KB
testcase_17 AC 200 ms
84,864 KB
testcase_18 AC 200 ms
84,736 KB
testcase_19 AC 201 ms
84,736 KB
testcase_20 AC 199 ms
84,736 KB
testcase_21 AC 209 ms
84,864 KB
testcase_22 AC 201 ms
84,864 KB
testcase_23 AC 202 ms
85,376 KB
testcase_24 AC 205 ms
85,632 KB
testcase_25 AC 207 ms
85,504 KB
testcase_26 AC 193 ms
90,496 KB
testcase_27 AC 194 ms
90,368 KB
testcase_28 AC 197 ms
90,112 KB
testcase_29 AC 209 ms
87,168 KB
testcase_30 AC 109 ms
74,368 KB
testcase_31 AC 149 ms
83,072 KB
testcase_32 AC 104 ms
73,216 KB
testcase_33 AC 122 ms
77,312 KB
testcase_34 AC 166 ms
85,376 KB
testcase_35 AC 236 ms
89,984 KB
testcase_36 AC 238 ms
89,984 KB
testcase_37 AC 230 ms
89,984 KB
testcase_38 AC 111 ms
74,496 KB
testcase_39 AC 189 ms
90,112 KB
testcase_40 AC 133 ms
79,872 KB
testcase_41 AC 261 ms
89,728 KB
testcase_42 AC 239 ms
89,984 KB
testcase_43 AC 234 ms
89,984 KB
testcase_44 AC 232 ms
89,856 KB
testcase_45 AC 225 ms
89,728 KB
testcase_46 AC 230 ms
89,984 KB
testcase_47 AC 230 ms
89,856 KB
testcase_48 AC 196 ms
84,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,os,io
input = sys.stdin.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
N = int(input())
A = list(map(int, input().split()))
n = int(N**.5)+1
cum = [[0]*(41) for _ in range(41)]
dp = [0]*N
dp[-1] = 1
MOD = 10**9+7
for i in range(N-1,-1,-1):
  if A[i]>1 and i<N-1:
    dp[i] += dp[i+1]
  if A[i]>40:
    for j in range(i+A[i],N,A[i]):
      dp[i] += dp[j]
  else:
    dp[i] += cum[A[i]][i%A[i]]
  dp[i] %= MOD
  for k in range(1,41):
    cum[k][i%k] += dp[i]
    cum[k][i%k] %= MOD
print(dp[0])
  
0