結果

問題 No.314 ケンケンパ
ユーザー KoshStormKoshStorm
提出日時 2017-12-18 01:20:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 1,000 ms
コード長 977 bytes
コンパイル時間 1,675 ms
コンパイル使用メモリ 167,968 KB
実行使用メモリ 57,700 KB
最終ジャッジ日時 2023-08-22 05:15:17
合計ジャッジ時間 3,104 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
56,624 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 4 ms
4,440 KB
testcase_17 AC 11 ms
8,620 KB
testcase_18 AC 42 ms
29,128 KB
testcase_19 AC 85 ms
57,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define dump1d_arr(array,i) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array,i,j) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define loINF (long)10000000000
#define shINF (short)10000
using namespace std;

typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
const LL mod = 1e9 + 7;

int main(void){
	long N;
	cin >> N;

	VVL dp(N+1, VL(3,0));
	dp[1][1] = 1;

	FOR(i,2,N+1){
		REP(j,3){
			if (j == 0) dp[i][j] = ((dp[i-1][1] + dp[i-1][2])%mod);
			else { dp[i][j] = ((dp[i-1][j-1]) % mod);}
		}
	}

	cout << ((dp[N][0] + dp[N][1] + dp[N][2]) % mod) << endl;




	return 0;
}
0