結果

問題 No.336 門松列列
ユーザー hirokazu1020hirokazu1020
提出日時 2016-01-15 23:00:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,024 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 92,700 KB
実行使用メモリ 28,168 KB
最終ジャッジ日時 2023-09-02 18:44:15
合計ジャッジ時間 1,488 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
25,688 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 17 ms
27,876 KB
testcase_05 AC 1 ms
4,372 KB
testcase_06 AC 5 ms
10,744 KB
testcase_07 AC 8 ms
17,144 KB
testcase_08 AC 12 ms
23,708 KB
testcase_09 AC 16 ms
27,908 KB
testcase_10 AC 16 ms
27,880 KB
testcase_11 AC 16 ms
28,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 1000000007



int dp[3001][3001];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;

	if (n<3) {
		cout << 0 << endl;
		return 0;
	}
	rep(i, n)dp[0][i] = 1;
	for (int i = 1; i < n; i++) {
		int c = 0;
		if (i & 1) {
			rep(j, n - i) {
				(c += dp[i - 1][j]) %= MOD;
				dp[i][j] = c;
			}
		}
		else {
			for (int j =  n - i; j >= 0; j--) {
				dp[i][j] = c;
				(c += dp[i - 1][j]) %= MOD;
			}
		}
	}
	cout << dp[n - 1][0] *2%MOD << endl;
	return 0;
}
0