結果

問題 No.336 門松列列
ユーザー 👑 kmjpkmjp
提出日時 2016-01-15 23:16:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,053 bytes
コンパイル時間 7,728 ms
コンパイル使用メモリ 145,628 KB
実行使用メモリ 126,748 KB
最終ジャッジ日時 2023-09-02 18:44:29
合計ジャッジ時間 3,729 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
126,724 KB
testcase_01 AC 106 ms
126,748 KB
testcase_02 AC 107 ms
126,640 KB
testcase_03 AC 107 ms
126,676 KB
testcase_04 AC 130 ms
126,692 KB
testcase_05 AC 106 ms
126,644 KB
testcase_06 AC 109 ms
126,708 KB
testcase_07 AC 115 ms
126,648 KB
testcase_08 AC 120 ms
126,712 KB
testcase_09 AC 127 ms
126,656 KB
testcase_10 AC 130 ms
126,668 KB
testcase_11 AC 129 ms
126,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;
ll mo=1000000007;
const int CN=4001;
ll C[CN][CN];

ll dp[2300];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,CN) for(j=0;j<=i;j++) C[i][j]=(j==0||j==i)?1:(C[i-1][j-1]+C[i-1][j])%mo;
	
	cin>>N;
	if(N<=2) return _P("0\n");
	
	dp[0]=dp[1]=dp[2]=1;
	dp[3]=2;
	for(i=3;i<=N-1;i++) {
		for(x=0;x<=i;x+=2) {
			(dp[i+1]+=C[i][x]*dp[x]%mo*dp[i-x])%=mo;
		}
		
	}
	
	
	cout<<dp[N]*2%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0