結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー naipianaipia
提出日時 2018-05-27 21:17:20
言語 C++11
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 254 bytes
コンパイル時間 1,299 ms
コンパイル使用メモリ 166,140 KB
実行使用メモリ 236,444 KB
最終ジャッジ日時 2024-06-30 07:19:07
合計ジャッジ時間 5,739 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 TLE * 1 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    long long N,M;
    map<long long,long long> mp;
    cin >> N >> M;

    mp[0]=0;
    mp[1]=1;

    for(int i=2;i<N;i++) mp[i]=(mp[i-1]+mp[i-2])%M;
    cout << mp[N-1] << endl;

    return 0;
}
0