結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー alex99724alex99724
提出日時 2021-11-04 13:22:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 90,844 KB
実行使用メモリ 42,368 KB
最終ジャッジ日時 2024-04-22 11:57:19
合計ジャッジ時間 1,798 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 21 ms
11,008 KB
testcase_11 AC 92 ms
42,240 KB
testcase_12 AC 92 ms
42,240 KB
testcase_13 AC 91 ms
42,240 KB
testcase_14 AC 91 ms
42,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<queue>
#include <functional>

using namespace std;
typedef long long ll;

long long MOD=998244353;

//yukicoder No.526

int main() {
    long long N,M;
    cin >> N >> M;
    vector<long long> F(N+1);
    F[1]=0;
    F[2]=1;
    for(int i=3;i<=N;i++){
        F[i]=F[i-1]+F[i-2];
        F[i]=F[i]%M;
    }
    cout << F[N] << endl;
}
0