結果

問題 No.336 門松列列
ユーザー maspymaspy
提出日時 2020-05-05 16:01:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 434 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 10,708 KB
実行使用メモリ 57,480 KB
最終ジャッジ日時 2023-09-02 18:46:00
合計ジャッジ時間 6,140 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 434 ms
29,724 KB
testcase_01 AC 129 ms
29,584 KB
testcase_02 AC 131 ms
29,836 KB
testcase_03 AC 130 ms
29,656 KB
testcase_04 AC 176 ms
29,848 KB
testcase_05 AC 131 ms
29,668 KB
testcase_06 AC 139 ms
29,832 KB
testcase_07 AC 150 ms
29,812 KB
testcase_08 AC 165 ms
29,824 KB
testcase_09 AC 177 ms
29,840 KB
testcase_10 AC 178 ms
29,708 KB
testcase_11 AC 177 ms
57,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# N log N があるが N^2 で

MOD = 10**9 + 7

N = int(read())

dp = np.array([1], np.int64)
for n in range(2, N + 1):
    newdp = np.zeros(n, np.int64)
    if n & 1:
        newdp[:-1] = np.cumsum(dp[::-1])[::-1]
    else:
        newdp[1:] = np.cumsum(dp)
    dp = newdp % MOD

x = 2 * dp.sum() % MOD
if N <= 2:
    x = 0
print(x)
0