結果
| 問題 |
No.336 門松列列
|
| コンテスト | |
| ユーザー |
btk
|
| 提出日時 | 2016-01-16 02:57:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 599 bytes |
| コンパイル時間 | 1,337 ms |
| コンパイル使用メモリ | 158,432 KB |
| 実行使用メモリ | 26,368 KB |
| 最終ジャッジ日時 | 2024-06-12 01:11:25 |
| 合計ジャッジ時間 | 2,240 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD=1e9+7;
int N;
LL dp[2016][2016];
LL sum[2017];
LL getsum(int n,int p,int t){
if(t)return (sum[n+1]-sum[p+1]+MOD)%MOD;
else return (sum[p+1])%MOD;
}
LL f(int n,int t){
if(n==N-1)fill(dp[N-1],dp[N-1]+N,1);
if(n==0)return dp[0][0];
sum[0]=0;
for(int i = 0; i <= n; i++)sum[i+1]=(sum[i]+dp[n][i])%MOD;
for(int i = 0; i < n; i++)dp[n-1][i]=getsum(n,i,t);
return f(n-1,1-t);
}
int main() {
cin>>N;
if(N<=2)cout<<0<<endl;
else cout<<(f(N-1,0)+f(N-1,1))%MOD<<endl;
return 0;
}
btk