結果

問題 No.314 ケンケンパ
ユーザー 777yuuki12323777yuuki12323
提出日時 2017-06-26 18:06:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 849 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 71,988 KB
実行使用メモリ 34,664 KB
最終ジャッジ日時 2024-04-15 01:54:13
合計ジャッジ時間 1,341 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
34,664 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 3 ms
7,744 KB
testcase_18 AC 8 ms
18,524 KB
testcase_19 AC 14 ms
34,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>


typedef long long ll;
#define fi first
#define se second
const ll mod = 1000000007;
//              123456789

using namespace std;

///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

ll cost[1123456][4];
ll ans;
int N;


int main(){
	
	int i;
	int j;
	
	cin>>N;
	
	fill( cost[0], cost[N], 0 );
	
	cost[1][1] = 1;
	
	for( i = 1; i <= N; i++ ){
		cost[i+1][1] = cost[i][3];
		cost[i+1][2] = cost[i][1];
		cost[i+1][3] = (cost[i][1]+cost[i][2])%mod;
	}
	
	for( i = 1; i < 4; i++ ){
		(ans += cost[N][i])%=mod;
	}
	
	cout<<ans<<endl;
	
}
0