結果

問題 No.314 ケンケンパ
ユーザー aaaaaa
提出日時 2018-11-10 11:10:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 1,199 bytes
コンパイル時間 959 ms
コンパイル使用メモリ 93,852 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2023-08-15 09:47:06
合計ジャッジ時間 1,864 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,876 KB
testcase_01 AC 4 ms
6,712 KB
testcase_02 AC 3 ms
6,700 KB
testcase_03 AC 3 ms
6,868 KB
testcase_04 AC 4 ms
6,860 KB
testcase_05 AC 4 ms
6,712 KB
testcase_06 AC 4 ms
6,852 KB
testcase_07 AC 3 ms
6,804 KB
testcase_08 AC 4 ms
6,852 KB
testcase_09 AC 3 ms
6,784 KB
testcase_10 AC 3 ms
6,716 KB
testcase_11 AC 3 ms
6,876 KB
testcase_12 AC 4 ms
6,940 KB
testcase_13 AC 3 ms
6,696 KB
testcase_14 AC 4 ms
6,708 KB
testcase_15 AC 3 ms
6,828 KB
testcase_16 AC 4 ms
6,856 KB
testcase_17 AC 4 ms
6,712 KB
testcase_18 AC 6 ms
6,920 KB
testcase_19 AC 8 ms
6,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>

using namespace std;


int main(){
	int i, j;
	int n;
	vector<int>dp(1000006, 0);


	cin >> n;

	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}

	//dp[1] = 1;
	//dp[2] = 1;

	//for (i = 1; i < n; i++) {
	for (i = 1; i < n; i++) {

		for (j = i + 2; j<n && j <= i + 3; j++) {
			dp[j] =  dp[i] + 1  +  ( dp[j] );
			//dp[j] = dp[i] + 1;
			dp[j] %= 1000000007;
		}

	}


	//cout << dp[n + 1 - ((n + 1) % 3)] << endl;
	cout << dp[n - 1] + 2 << endl;

	long maxn = 0, index = 0;

	/*for (i = n - 2; i <= n + 1; i++) {
		if (maxn < dp[i]) {
			maxn = dp[i];
			index = i;
		}
	}

	if (index < n) {
		cout << maxn + ((n + 1) - index) << endl;
	}
	else {
		cout << maxn << endl;
	}
*/
	//cout << dp[n + 1] << endl;

	//long sum = 0;

	/*for (i = 0; i < n; i++) {
		sum += dp[i];
		sum %= 1000000007;
	}
	cout << sum << endl;
*/







	getchar();
	getchar();
	return 0;
}
0