結果

問題 No.314 ケンケンパ
ユーザー takune1024takune1024
提出日時 2017-11-29 23:59:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 688 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 66,428 KB
実行使用メモリ 26,736 KB
最終ジャッジ日時 2023-08-18 13:51:10
合計ジャッジ時間 1,385 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))

const int inf = 999999999;
const int mod = 1000000007;

ll dp[1000010][3];

int main(){
	int n; cin >> n;
	dp[1][0] = 0; dp[1][1] = 1; dp[1][2] = 0;
	For(i, 2, n + 1){
		dp[i][0] = dp[i - 1][1] + dp[i - 1][2];
		dp[i][1] = dp[i - 1][0];
		dp[i][2] = dp[i - 1][1];
		Rep(j, 3){
			dp[i][j] %= mod;
		}
	}
	int ans = 0;
	Rep(i, 3){
		ans += dp[n][i];
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}
0