結果

問題 No.1331 Moving Penguin
ユーザー H3PO4H3PO4
提出日時 2022-03-19 09:18:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 520 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 54,264 KB
最終ジャッジ日時 2024-04-14 22:10:49
合計ジャッジ時間 8,570 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 627 ms
50,816 KB
testcase_01 AC 517 ms
43,864 KB
testcase_02 AC 510 ms
43,612 KB
testcase_03 AC 510 ms
43,864 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import isqrt
import numpy as np

N = int(input())
A = map(int, input().split())
sq = isqrt(N)
MOD = 10 ** 9 + 7

dp = np.zeros(N, dtype=np.int64)
dp[0] = 1

small_a = np.zeros((sq, sq), dtype=np.int64)
ar = np.arange(1, sq)
for i, a in enumerate(A):
    dp[i] += np.sum(small_a[ar, i % ar])
    dp[i] %= MOD

    if i + 1 < N and a != 1:
        dp[i + 1] += dp[i]

    if sq <= a:
        dp[i + a::a] += dp[i]
    else:
        small_a[a, i % a] += dp[i]
        small_a[a, i % a] %= MOD
print(dp[-1] % MOD)
0