結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー trineutrontrineutron
提出日時 2019-07-28 19:27:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 282 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 164,004 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-15 11:35:32
合計ジャッジ時間 3,011 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 80 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long n, m;
    cin >> n >> m;
    long prev = 0, current = 1;
    for (long i = 2; i <= n; i++) {
        long w = (current + prev) % m;
        prev = current;
        current = w;
    }
    cout << current << endl;
}
0