結果

問題 No.44 DPなすごろく
ユーザー hotpepsi
提出日時 2015-06-19 23:33:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 377 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 60,260 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 04:21:07
合計ジャッジ時間 1,233 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	string s;
	getline(cin, s);
	LL N = atoi(s.c_str());
	LL dp[64] = {};
	dp[0] = 1;
	for (LL i = 1; i <= N; ++i) {
		dp[i] = dp[i - 1];
		if (i > 1) {
			dp[i] += dp[i - 2];
		}
	}
	cout << dp[N] << endl;
	return 0;
}
0