結果

問題 No.314 ケンケンパ
ユーザー chuka231chuka231
提出日時 2015-12-08 00:12:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 15 ms / 1,000 ms
コード長 342 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 56,964 KB
実行使用メモリ 11,344 KB
最終ジャッジ日時 2023-10-12 20:17:46
合計ジャッジ時間 1,526 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <string>
#include <iostream>
#include <cmath>
using namespace std;

long long int mod = 1000000007;
int n;
long long int ans[1000006];

int main()
{
	cin >> n;

	ans[0] = 0;
	ans[1] = 1;
	ans[2] = 2;
	ans[3] = 2;

	for (int i = 4; i <= n; i++) {
		ans[i] = (ans[i - 2] + ans[i - 3]) % mod;
	}

	cout << ans[n] << endl;

	return 0;
}
0