結果

問題 No.1331 Moving Penguin
ユーザー penguinmanpenguinman
提出日時 2020-10-28 22:57:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 868 ms / 1,500 ms
コード長 583 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 91,648 KB
最終ジャッジ日時 2024-04-25 04:32:20
合計ジャッジ時間 32,703 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
65,920 KB
testcase_01 AC 42 ms
52,352 KB
testcase_02 AC 41 ms
52,352 KB
testcase_03 AC 43 ms
52,480 KB
testcase_04 AC 729 ms
91,648 KB
testcase_05 AC 728 ms
87,168 KB
testcase_06 AC 727 ms
87,424 KB
testcase_07 AC 721 ms
87,296 KB
testcase_08 AC 722 ms
86,784 KB
testcase_09 AC 723 ms
86,784 KB
testcase_10 AC 724 ms
86,528 KB
testcase_11 AC 725 ms
87,040 KB
testcase_12 AC 720 ms
86,656 KB
testcase_13 AC 725 ms
86,784 KB
testcase_14 AC 728 ms
87,040 KB
testcase_15 AC 737 ms
87,040 KB
testcase_16 AC 721 ms
86,912 KB
testcase_17 AC 720 ms
86,144 KB
testcase_18 AC 719 ms
86,528 KB
testcase_19 AC 719 ms
86,400 KB
testcase_20 AC 723 ms
85,888 KB
testcase_21 AC 723 ms
86,400 KB
testcase_22 AC 724 ms
86,272 KB
testcase_23 AC 731 ms
86,912 KB
testcase_24 AC 718 ms
86,656 KB
testcase_25 AC 722 ms
86,656 KB
testcase_26 AC 731 ms
91,392 KB
testcase_27 AC 735 ms
91,392 KB
testcase_28 AC 737 ms
91,520 KB
testcase_29 AC 716 ms
89,216 KB
testcase_30 AC 194 ms
74,368 KB
testcase_31 AC 358 ms
81,408 KB
testcase_32 AC 175 ms
73,216 KB
testcase_33 AC 266 ms
77,184 KB
testcase_34 AC 436 ms
86,144 KB
testcase_35 AC 792 ms
90,880 KB
testcase_36 AC 788 ms
90,752 KB
testcase_37 AC 810 ms
91,008 KB
testcase_38 AC 210 ms
75,520 KB
testcase_39 AC 701 ms
91,392 KB
testcase_40 AC 310 ms
79,616 KB
testcase_41 AC 726 ms
87,296 KB
testcase_42 AC 812 ms
91,008 KB
testcase_43 AC 822 ms
91,008 KB
testcase_44 AC 822 ms
90,880 KB
testcase_45 AC 859 ms
90,880 KB
testcase_46 AC 868 ms
90,880 KB
testcase_47 AC 859 ms
90,880 KB
testcase_48 AC 715 ms
86,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N=int(input())
mod=(int)(1e9+7)
A=list(map(int,input().split()))
dp=[0]*N
dp[0]=1
M=int(math.sqrt(N))
Sum=[[0]*(M+1) for i in range(M+1)]
for i in range(N):
    if i>0 and A[i-1]!=1:
        dp[i]+=dp[i-1];
        dp[i]%=mod
    for j in range(M+1):
        if j>0:
            dp[i]+=Sum[j][i%j]
            dp[i]%=mod
    if A[i]<=M:
        Sum[A[i]][i%A[i]]+=dp[i]
        Sum[A[i]][i%A[i]]%=mod
    else:
        for j in range(N):
            X=j*A[i]+A[i]+i
            if X>=N:
                break
            dp[X]+=dp[i]
            dp[X]%=mod
print(dp[N-1])
0