結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 791 ms
51,268 KB
testcase_01 AC 505 ms
44,076 KB
testcase_02 AC 508 ms
44,080 KB
testcase_03 AC 513 ms
44,080 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, dtype=int)
for i, a in enumerate(A):
    dp[i] += np.sum(small_a[ar, i % ar])
    dp[i] %= MOD
    dpi = dp[i]
    if i + 1 < N and a != 1:
        dp[i + 1] += dpi

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