結果

問題 No.44 DPなすごろく
ユーザー ふう
提出日時 2015-02-07 13:09:30
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 628 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 607 ms
コンパイル使用メモリ 105,428 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 04:15:35
合計ジャッジ時間 1,224 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'long long int fibo(int)':
main.cpp:36:20: warning: 'res' may be used uninitialized [-Wmaybe-uninitialized]
   36 |         return (res);
      |                    ^
main.cpp:27:12: note: 'res' was declared here
   27 |         ll res;
      |            ^~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
                 from main.cpp:3:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:45:20:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:212:25: warning: 'res' may be used uninitialized [-Wmaybe-uninitialized]
  212 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:27:12: note: 'res' was declared here
   27 |         ll res;
      |            ^~~

ソースコード

diff #
raw source code

#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