結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー fumi6328fumi6328
提出日時 2018-10-09 19:26:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 315 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 165,336 KB
実行使用メモリ 42,340 KB
最終ジャッジ日時 2023-08-02 19:02:41
合計ジャッジ時間 2,711 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
42,292 KB
testcase_01 AC 12 ms
42,336 KB
testcase_02 AC 13 ms
42,296 KB
testcase_03 AC 12 ms
42,304 KB
testcase_04 AC 12 ms
42,136 KB
testcase_05 AC 12 ms
42,228 KB
testcase_06 AC 13 ms
42,212 KB
testcase_07 AC 13 ms
42,292 KB
testcase_08 AC 12 ms
42,184 KB
testcase_09 AC 14 ms
42,168 KB
testcase_10 AC 28 ms
42,340 KB
testcase_11 AC 88 ms
42,232 KB
testcase_12 AC 87 ms
42,292 KB
testcase_13 AC 84 ms
42,196 KB
testcase_14 AC 84 ms
42,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    ll n,m;
    cin >> n >> m;
    vector<ll> f(5000001);
    f[0] = 0,f[1] = 1;
    for(int i = 2; i < n; i++){
        f[i] = f[i-1] + f[i-2];
        f[i] %= m;
    }

    cout << f[n-1] << endl;

    return 0;
}
0