結果

問題 No.1331 Moving Penguin
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-09-13 11:28:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,006 ms / 1,500 ms
コード長 757 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 95,092 KB
最終ジャッジ日時 2023-09-13 11:28:56
合計ジャッジ時間 42,591 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
78,280 KB
testcase_01 AC 106 ms
72,988 KB
testcase_02 AC 107 ms
72,800 KB
testcase_03 AC 107 ms
72,792 KB
testcase_04 AC 930 ms
94,904 KB
testcase_05 AC 944 ms
92,400 KB
testcase_06 AC 948 ms
92,508 KB
testcase_07 AC 946 ms
92,392 KB
testcase_08 AC 924 ms
92,012 KB
testcase_09 AC 955 ms
92,212 KB
testcase_10 AC 982 ms
92,192 KB
testcase_11 AC 973 ms
92,160 KB
testcase_12 AC 919 ms
92,204 KB
testcase_13 AC 921 ms
92,304 KB
testcase_14 AC 948 ms
92,156 KB
testcase_15 AC 950 ms
92,320 KB
testcase_16 AC 922 ms
91,996 KB
testcase_17 AC 929 ms
94,392 KB
testcase_18 AC 982 ms
94,364 KB
testcase_19 AC 927 ms
94,216 KB
testcase_20 AC 932 ms
94,348 KB
testcase_21 AC 933 ms
94,092 KB
testcase_22 AC 936 ms
94,348 KB
testcase_23 AC 958 ms
92,172 KB
testcase_24 AC 925 ms
92,028 KB
testcase_25 AC 956 ms
92,192 KB
testcase_26 AC 913 ms
95,092 KB
testcase_27 AC 937 ms
95,080 KB
testcase_28 AC 934 ms
94,932 KB
testcase_29 AC 927 ms
93,064 KB
testcase_30 AC 274 ms
81,800 KB
testcase_31 AC 460 ms
87,136 KB
testcase_32 AC 243 ms
80,860 KB
testcase_33 AC 354 ms
83,396 KB
testcase_34 AC 561 ms
89,528 KB
testcase_35 AC 958 ms
94,724 KB
testcase_36 AC 986 ms
94,496 KB
testcase_37 AC 984 ms
94,724 KB
testcase_38 AC 282 ms
81,896 KB
testcase_39 AC 890 ms
94,768 KB
testcase_40 AC 398 ms
86,216 KB
testcase_41 AC 932 ms
94,692 KB
testcase_42 AC 948 ms
94,696 KB
testcase_43 AC 963 ms
94,732 KB
testcase_44 AC 1,006 ms
94,764 KB
testcase_45 AC 980 ms
94,784 KB
testcase_46 AC 975 ms
94,596 KB
testcase_47 AC 1,000 ms
94,776 KB
testcase_48 AC 921 ms
92,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N = int(input())
A = [0]+list(map(int,input().split()))

mod = 10**9 + 7

B = math.ceil(math.sqrt(N))
S = [[0]*(B+1) for _ in range(B)]
dp = [0]*(N+1)

dp[1] = 1
a = A[1]
if a>B:
    for i in range(1+a,N+1,a):
        dp[i] = (dp[i]+dp[1])%mod
else:
    S[1%a][a] = (S[1%a][a] + dp[1])%mod
    
for i in range(2,N+1):
    
    if A[i-1]!=1:
        dp[i] = (dp[i]+dp[i-1])%mod
    
    for j in range(1,B+1):
        dp[i] = (dp[i] + S[i%j][j])%mod
    
    a = A[i]
    if a>B:
        for j in range(i+a,N+1,a):
            dp[j] = (dp[j]+dp[i])%mod
    else:
        S[i%a][a] = (S[i%a][a] + dp[i])%mod
print(dp[-1])
0