結果

問題 No.1331 Moving Penguin
ユーザー roarisroaris
提出日時 2021-06-03 18:48:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 751 ms / 1,500 ms
コード長 570 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 91,136 KB
最終ジャッジ日時 2024-04-25 05:20:12
合計ジャッジ時間 29,431 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
66,304 KB
testcase_01 AC 38 ms
52,352 KB
testcase_02 AC 36 ms
52,352 KB
testcase_03 AC 36 ms
52,096 KB
testcase_04 AC 680 ms
91,008 KB
testcase_05 AC 654 ms
86,656 KB
testcase_06 AC 669 ms
86,656 KB
testcase_07 AC 659 ms
87,040 KB
testcase_08 AC 656 ms
86,144 KB
testcase_09 AC 660 ms
86,144 KB
testcase_10 AC 675 ms
86,400 KB
testcase_11 AC 689 ms
86,400 KB
testcase_12 AC 677 ms
86,400 KB
testcase_13 AC 666 ms
86,272 KB
testcase_14 AC 668 ms
86,272 KB
testcase_15 AC 671 ms
86,656 KB
testcase_16 AC 668 ms
86,656 KB
testcase_17 AC 668 ms
85,632 KB
testcase_18 AC 660 ms
86,016 KB
testcase_19 AC 679 ms
86,016 KB
testcase_20 AC 660 ms
85,632 KB
testcase_21 AC 650 ms
85,632 KB
testcase_22 AC 659 ms
85,760 KB
testcase_23 AC 658 ms
86,400 KB
testcase_24 AC 664 ms
86,144 KB
testcase_25 AC 661 ms
86,144 KB
testcase_26 AC 675 ms
91,008 KB
testcase_27 AC 667 ms
91,008 KB
testcase_28 AC 676 ms
91,136 KB
testcase_29 AC 660 ms
88,448 KB
testcase_30 AC 171 ms
73,984 KB
testcase_31 AC 330 ms
83,584 KB
testcase_32 AC 153 ms
73,344 KB
testcase_33 AC 313 ms
77,824 KB
testcase_34 AC 402 ms
85,888 KB
testcase_35 AC 707 ms
90,752 KB
testcase_36 AC 719 ms
90,624 KB
testcase_37 AC 713 ms
90,624 KB
testcase_38 AC 187 ms
75,520 KB
testcase_39 AC 656 ms
90,880 KB
testcase_40 AC 278 ms
80,512 KB
testcase_41 AC 662 ms
87,424 KB
testcase_42 AC 731 ms
90,752 KB
testcase_43 AC 725 ms
90,624 KB
testcase_44 AC 718 ms
90,880 KB
testcase_45 AC 751 ms
90,752 KB
testcase_46 AC 738 ms
90,496 KB
testcase_47 AC 749 ms
90,624 KB
testcase_48 AC 664 ms
85,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
M = int(N**0.5)
dp = [0]*N
dp[0] = 1
acc = [[0]*M for _ in range(M)]
MOD = 10**9+7

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(1, M):
        dp[i] += acc[j][(i+1)%j]
        dp[i] %= MOD
    
    if A[i]>=M:
        for j in range(i+A[i], N, A[i]):
            dp[j] += dp[i]
            dp[j] %= MOD
    else:
        acc[A[i]][(i+1)%A[i]] += dp[i]
        acc[A[i]][(i+1)%A[i]] %= MOD

print(dp[N-1])
0