結果
| 問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
| コンテスト | |
| ユーザー |
kpinkcat
|
| 提出日時 | 2023-08-17 14:09:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 82 ms / 2,000 ms |
| コード長 | 451 bytes |
| コンパイル時間 | 1,125 ms |
| コンパイル使用メモリ | 102,096 KB |
| 最終ジャッジ日時 | 2025-02-16 08:54:22 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
In file included from /usr/include/c++/13/iostream:41,
from main.cpp:1:
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:26:13:
/usr/include/c++/13/ostream:204:25: warning: ‘f3’ may be used uninitialized [-Wmaybe-uninitialized]
204 | { return _M_insert(__n); }
| ~~~~~~~~~^~~~~
main.cpp: In function ‘int main()’:
main.cpp:18:37: note: ‘f3’ was declared here
18 | long long n, m, f1 = 0, f2 = 1, f3;
| ^~
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
using namespace std;
#ifdef _WIN32
#include <Windows.h>
#endif
int main()
{
long long n, m, f1 = 0, f2 = 1, f3;
cin >> n >> m;
for (int i = 2; i < n; i++){
long long t;
f3 = (f1 + f2)%m;
f1 = f2;
f2 = f3;
}
cout << f3 << endl;
}
kpinkcat