結果

問題 No.314 ケンケンパ
ユーザー ramia777ramia777
提出日時 2022-05-25 23:31:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 1,198 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 95,196 KB
実行使用メモリ 11,024 KB
最終ジャッジ日時 2023-10-20 19:15:58
合計ジャッジ時間 1,753 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//Yukicoder
//Q314 ken-pa


//二次元可変配列
//vector <vector <int>> mass;
//vector <vector <int>> memo;

//#include "stdafx.h"
#include <iostream>
#include <vector>
#include <list>//list
#include <set> //tree
#include <map> //連想配列
#include <unordered_set> //hash
#include <unordered_map> //hash
#include <algorithm>
#include <iomanip>

using namespace std;
typedef unsigned long long LL;


#define START (0)
#define RIGHT (1)
#define UP    (2)
#define LEFT  (3)
#define DOWN  (4)

#define DATA_MAX (1000000)
#define FMAX(a,b)  ((a)>(b)?(a):(b))
#define FMIX(a,b)  ((a)<(b)?(a):(b))


vector <vector <LL>> memo2;
vector<LL> memo1;
vector<LL> T;
vector<LL> K;
vector<LL> dp;

LL N, D;
LL ans = 0;





int main()
{
	LL total = 0;

	cin >> N;


	dp.resize(N + 10);



	if (N == 1)
	{
		cout << 1 << endl;
		return 0;
	}
	else
	if (N == 2)
	{
		cout << 2 << endl;
		return 0;
	}
	else
	if (N == 3)
	{
		cout << 2 << endl;
		return 0;
	}


	// 初期値
	dp[0] = 1; dp[1] = 2; dp[2] = 2;

	LL n = 3;

	while (1)
	{
		
		dp[n] = (dp[n - 2] + dp[n - 3]) % 1000000007; //毎回 mod を取る
		n++;
		if (n >= N)
			break;
	}


	cout << dp[n-1]  << endl;

	//getchar();
	return 0; //end
}

0