結果

問題 No.1331 Moving Penguin
ユーザー persimmon_t01persimmon_t01
提出日時 2021-01-09 08:50:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,356 ms / 1,500 ms
コード長 669 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 91,776 KB
最終ジャッジ日時 2024-04-25 05:01:15
合計ジャッジ時間 49,024 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
64,896 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 AC 38 ms
52,352 KB
testcase_03 AC 37 ms
52,096 KB
testcase_04 AC 1,092 ms
91,136 KB
testcase_05 AC 1,089 ms
90,752 KB
testcase_06 AC 1,133 ms
90,368 KB
testcase_07 AC 1,157 ms
90,624 KB
testcase_08 AC 1,128 ms
90,368 KB
testcase_09 AC 1,126 ms
90,368 KB
testcase_10 AC 1,112 ms
90,368 KB
testcase_11 AC 1,123 ms
90,240 KB
testcase_12 AC 1,115 ms
89,984 KB
testcase_13 AC 1,123 ms
90,240 KB
testcase_14 AC 1,121 ms
90,240 KB
testcase_15 AC 1,142 ms
90,240 KB
testcase_16 AC 1,098 ms
90,240 KB
testcase_17 AC 1,138 ms
90,112 KB
testcase_18 AC 1,149 ms
90,496 KB
testcase_19 AC 1,126 ms
90,368 KB
testcase_20 AC 1,140 ms
89,984 KB
testcase_21 AC 1,140 ms
90,240 KB
testcase_22 AC 1,119 ms
89,984 KB
testcase_23 AC 1,126 ms
90,240 KB
testcase_24 AC 1,127 ms
90,112 KB
testcase_25 AC 1,139 ms
90,240 KB
testcase_26 AC 1,138 ms
91,520 KB
testcase_27 AC 1,112 ms
91,136 KB
testcase_28 AC 1,136 ms
91,392 KB
testcase_29 AC 1,148 ms
91,776 KB
testcase_30 AC 257 ms
73,600 KB
testcase_31 AC 547 ms
83,456 KB
testcase_32 AC 223 ms
73,216 KB
testcase_33 AC 366 ms
77,824 KB
testcase_34 AC 667 ms
85,888 KB
testcase_35 AC 1,243 ms
90,880 KB
testcase_36 AC 1,279 ms
91,136 KB
testcase_37 AC 1,261 ms
90,624 KB
testcase_38 AC 276 ms
76,160 KB
testcase_39 AC 1,086 ms
91,136 KB
testcase_40 AC 460 ms
80,768 KB
testcase_41 AC 1,171 ms
90,880 KB
testcase_42 AC 1,268 ms
91,264 KB
testcase_43 AC 1,271 ms
90,624 KB
testcase_44 AC 1,281 ms
90,752 KB
testcase_45 AC 1,334 ms
90,752 KB
testcase_46 AC 1,337 ms
91,008 KB
testcase_47 AC 1,356 ms
91,008 KB
testcase_48 AC 1,139 ms
90,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main1(n,a):
  mod=10**9+7
  dp=[0]*(n+1)
  dp[1]=1
  bd=int(n**0.5)
  memo=[[0]*(bd+1) for _ in range(bd+1)]
  dp[1]=1
  num1=0
  for i in range(1,n+1):
    x=a[i-1]
    for j in range(1,bd+1):
      dp[i]+=memo[j][i%j]
      dp[i]%=mod
    dp[i]+=num1
    dp[i]%=mod
    if dp[i]==0:continue
    if i==n:break
    dp[i+1]+=dp[i]
    dp[i+1]%=mod
    if x>bd:
      now=i+x
      while now<=n:
        dp[now]+=dp[i]
        dp[now]%=mod
        now+=x
    elif x==1:
      num1+=dp[i]
      num1%=mod
      dp[i+1]-=dp[i]
    else:
      memo[x][i%x]+=dp[i]
      memo[x][i%x]%=mod
  return dp[n]

n=int(input())
a=list(map(int,input().split()))
print(main1(n,a))
0