結果

問題 No.44 DPなすごろく
ユーザー snrnsidy
提出日時 2021-02-28 20:15:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 704 bytes
コンパイル時間 996 ms
コンパイル使用メモリ 112,996 KB
最終ジャッジ日時 2025-01-19 08:16:51
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;

long long int dp[51];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	dp[0] = 1;

	for (int i = 1; i <= 50; i++)
	{
		if (i - 1 >= 0)
		{
			dp[i] += dp[i - 1];
		}
		if (i - 2 >= 0)
		{
			dp[i] += dp[i - 2];
		}
	}

	int n;
	
	cin >> n;

	cout << dp[n] << '\n';

	return 0;
}
0