結果

問題 No.44 DPなすごろく
ユーザー ふう
提出日時 2015-02-07 13:09:30
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 628 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 83,304 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-23 10:38:43
合計ジャッジ時間 1,464 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘long long int fibo(int)’:
main.cpp:27:12: warning: ‘res’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |         ll res;
      |            ^~~

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>

#define ll long long
#define SIZE 10001

using namespace std;

/* フィボナッチ数列 */
ll fibo(int n)
{
	ll a = 0;
	ll b = 1;
	ll res;
	int i;

	if (n == 0 || n == 1) return (n);
	for (i = 2; i <= n; i++) {
		res = a + b;
		a = b;
		b = res;
	}
	return (res);
}

int main()
{
	int N;

	cin >> N;

	cout << fibo(N + 1) << endl;
}

0