結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー shiomusubi496
提出日時 2021-05-01 17:32:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 197 bytes
コンパイル時間 1,754 ms
コンパイル使用メモリ 192,952 KB
最終ジャッジ日時 2025-01-21 05:22:56
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int N,M; cin>>N>>M;
    ll a=0,b=1;
    while(--N){
        swap(a,b);
        (b+=a)%=M;
    }
    cout<<a<<endl;
}
0