結果

問題 No.44 DPなすごろく
ユーザー syake_ta
提出日時 2018-08-28 19:13:57
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 402 bytes
コンパイル時間 911 ms
コンパイル使用メモリ 66,604 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-17 23:51:14
合計ジャッジ時間 1,328 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = (int)1e9 + 1;

ll dp[51];

int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		dp[i] = 0;
	}
	dp[1] = 1, dp[2] = 2;
	for (int i = 3; i <= n; i++) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	cout << dp[n] << endl;
	return 0;
}
0