結果

問題 No.336 門松列列
ユーザー vwxyzvwxyz
提出日時 2024-04-15 10:17:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,188 ms / 2,000 ms
コード長 385 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-15 10:17:28
合計ジャッジ時間 9,527 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 935 ms
11,008 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 1,186 ms
11,136 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 157 ms
10,880 KB
testcase_07 AC 431 ms
10,880 KB
testcase_08 AC 812 ms
11,008 KB
testcase_09 AC 1,147 ms
11,008 KB
testcase_10 AC 1,139 ms
11,136 KB
testcase_11 AC 1,188 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
if N in (1,2):
    ans=0
else:
    mod=10**9+7
    dp=[1]
    for i in range(1,N):
        prev=[0]+dp
        for j in range(1,i+1):
            prev[j]+=prev[j-1]
            prev[j]%=mod
        if i%2:
            dp=[(prev[j]-prev[0])%mod for j in range(i+1)]
        else:
            dp=[(prev[i]-prev[j])%mod for j in range(i+1)]
    ans=sum(dp)*2%mod
print(ans)
0