結果
問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
ユーザー | f843nmfwisfeuw |
提出日時 | 2020-09-14 20:24:50 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 178 ms / 2,000 ms |
コード長 | 532 bytes |
コンパイル時間 | 672 ms |
コンパイル使用メモリ | 90,044 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-04 00:47:06 |
合計ジャッジ時間 | 2,214 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 5 ms
4,376 KB |
testcase_10 | AC | 37 ms
4,380 KB |
testcase_11 | AC | 177 ms
4,380 KB |
testcase_12 | AC | 177 ms
4,376 KB |
testcase_13 | AC | 177 ms
4,376 KB |
testcase_14 | AC | 178 ms
4,380 KB |
コンパイルメッセージ
次のファイルから読み込み: /usr/local/gcc7/include/c++/12.2.0/iostream:39, 次から読み込み: main.cpp:1: メンバ関数 ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>]’ 内, inlined from ‘int main()’ at main.cpp:33:13: /usr/local/gcc7/include/c++/12.2.0/ostream:167:25: 警告: ‘F3’ may be used uninitialized [-Wmaybe-uninitialized] 167 | { return _M_insert(__n); } | ~~~~~~~~~^~~~~ main.cpp: 関数 ‘int main()’ 内: main.cpp:26:10: 備考: ‘F3’ はここで定義されています 26 | long F3; | ^~
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> #include <stack> #include <algorithm> #include <string> #include <map> #include <iterator> #include <set> #include <queue> #include <bitset> #include <cassert> using namespace std; int main() { long N, M; cin >> N >> M; long F1 = 0; long F2 = 1; long F3; for (int i = 3; i <= N; ++i) { F3 = ((F2 % M) + (F1 % M)) % M; F1 = F2; F2 = F3; } cout << F3 << endl; return 0; }