結果

問題 No.44 DPなすごろく
ユーザー myanta
提出日時 2017-05-10 22:42:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 319 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 36,608 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 07:13:55
合計ジャッジ時間 1,122 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<vector>


using namespace std;
using ll=long long int;


ll solve(int n)
{
	vector<ll> f;

	f.resize(n+1);
	f[0]=f[1]=1;
	for(int i=2;i<=n;i++)
	{
		f[i]=f[i-1]+f[i-2];
	}
	return f[n];
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		printf("%lld\n", solve(n));
	}

	return 0;
}
0