結果

問題 No.314 ケンケンパ
ユーザー takiteketakiteke
提出日時 2017-08-16 20:12:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 1,000 ms
コード長 638 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 69,996 KB
実行使用メモリ 26,880 KB
最終ジャッジ日時 2024-04-21 14:16:21
合計ジャッジ時間 1,276 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
26,496 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 4 ms
5,888 KB
testcase_18 AC 7 ms
14,848 KB
testcase_19 AC 10 ms
26,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

static const ll MOD = 1000000007;
ll dp[3][1000006];//ケンケン,ケンパ,パケンの3パターン×N

int main() {
	ll N;
	cin >> N;
	

	dp[0][1] = 0; dp[1][1] = 0; dp[2][1] = 1;
	for (int i = 2;i <= N;i++) {
		dp[0][i] = dp[2][i - 1] % MOD;
		dp[1][i] = ( dp[0][i - 1] + dp[2][i - 1] ) % MOD;
		dp[2][i] = dp[1][i - 1] % MOD;
	}

	ll ans = ( dp[0][N] + dp[1][N] + dp[2][N] ) % MOD;

	cout << ans << endl;
	//return 0;
}
0