結果

問題 No.1331 Moving Penguin
ユーザー rlangevinrlangevin
提出日時 2023-09-29 00:04:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 868 ms / 1,500 ms
コード長 539 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 93,612 KB
最終ジャッジ日時 2023-09-29 00:05:25
合計ジャッジ時間 35,148 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
77,360 KB
testcase_01 AC 71 ms
71,552 KB
testcase_02 AC 74 ms
71,660 KB
testcase_03 AC 72 ms
71,744 KB
testcase_04 AC 760 ms
93,612 KB
testcase_05 AC 748 ms
92,016 KB
testcase_06 AC 772 ms
91,880 KB
testcase_07 AC 739 ms
91,876 KB
testcase_08 AC 763 ms
91,928 KB
testcase_09 AC 765 ms
91,816 KB
testcase_10 AC 729 ms
90,668 KB
testcase_11 AC 754 ms
90,660 KB
testcase_12 AC 740 ms
91,664 KB
testcase_13 AC 760 ms
91,744 KB
testcase_14 AC 751 ms
91,820 KB
testcase_15 AC 736 ms
91,816 KB
testcase_16 AC 758 ms
91,556 KB
testcase_17 AC 729 ms
90,708 KB
testcase_18 AC 757 ms
90,668 KB
testcase_19 AC 734 ms
90,704 KB
testcase_20 AC 749 ms
90,556 KB
testcase_21 AC 759 ms
90,608 KB
testcase_22 AC 737 ms
90,696 KB
testcase_23 AC 759 ms
90,632 KB
testcase_24 AC 747 ms
90,560 KB
testcase_25 AC 750 ms
90,608 KB
testcase_26 AC 796 ms
92,876 KB
testcase_27 AC 755 ms
92,840 KB
testcase_28 AC 790 ms
93,100 KB
testcase_29 AC 741 ms
93,204 KB
testcase_30 AC 225 ms
80,468 KB
testcase_31 AC 385 ms
84,912 KB
testcase_32 AC 197 ms
80,068 KB
testcase_33 AC 284 ms
82,884 KB
testcase_34 AC 469 ms
87,260 KB
testcase_35 AC 791 ms
92,328 KB
testcase_36 AC 821 ms
92,216 KB
testcase_37 AC 816 ms
92,328 KB
testcase_38 AC 231 ms
80,812 KB
testcase_39 AC 716 ms
92,704 KB
testcase_40 AC 337 ms
83,968 KB
testcase_41 AC 728 ms
91,204 KB
testcase_42 AC 825 ms
92,372 KB
testcase_43 AC 794 ms
92,152 KB
testcase_44 AC 806 ms
92,324 KB
testcase_45 AC 868 ms
92,244 KB
testcase_46 AC 838 ms
92,148 KB
testcase_47 AC 824 ms
92,404 KB
testcase_48 AC 757 ms
90,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
B = int(N ** 0.5)
dp = [0] * N
dp_sum = [[0] * B for _ in range(B + 1)]
dp[0] = 1
for i in range(N):
    if i:
        if A[i - 1] != 1:
            dp[i] += dp[i - 1]
            dp[i] %= mod
    for b in range(1, B + 1):
        dp[i] += dp_sum[b][i%b]
    if A[i] <= B:
        dp_sum[A[i]][i%A[i]] += dp[i]
        dp_sum[A[i]][i%A[i]] %= mod
    else:
        for j in range(i + A[i], N, A[i]):
            dp[j] += dp[i]
            dp[j] %= mod

print(dp[-1]%mod)
0