結果

問題 No.314 ケンケンパ
ユーザー autumn-eelautumn-eel
提出日時 2016-12-11 09:49:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 1,000 ms
コード長 457 bytes
コンパイル時間 1,517 ms
コンパイル使用メモリ 163,008 KB
実行使用メモリ 27,024 KB
最終ジャッジ日時 2023-08-19 11:09:18
合計ジャッジ時間 2,392 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
26,520 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 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 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 4 ms
7,628 KB
testcase_18 AC 6 ms
15,744 KB
testcase_19 AC 10 ms
27,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define MOD 1000000007
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll dp[1000001][3];//何回目でその時けんは何回続いてるか
int main() {
	int n; scanf("%d", &n);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = (dp[i - 1][1] + dp[i - 1][2]) % MOD;
		for (int j = 1; j <= 2; j++)dp[i][j] = dp[i - 1][j - 1];
	}
	printf("%lld\n", (dp[n][0] + dp[n][1] + dp[n][2]) % MOD);
}
0