結果

問題 No.44 DPなすごろく
ユーザー dora_maruta
提出日時 2014-11-11 15:41:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 427 bytes
コンパイル時間 660 ms
コンパイル使用メモリ 55,412 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-31 09:39:27
合計ジャッジ時間 1,638 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>

unsigned long long field[51];

unsigned long long func(unsigned long long n){
	if (n == 1)return field[n] = 1;
	if (n == 2)return field[n] = 2;
	if (field[n] != 0)return field[n];
	return field[n] = func(n - 1) + func(n - 2);
}

int main(){
	unsigned long long n;
	std::cin >> n;
	
	//for (int i = 0; i < 50; ++i)std::cout << field[i]<<" ";
	std::cout << func(n) << std::endl;
	return 0;
}
0