結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー kikage
提出日時 2020-04-03 01:08:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 226 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 55,812 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-28 15:29:15
合計ジャッジ時間 1,302 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main(){
    int N,M,f1=0,f2=1,tmp;
    cin >> N >> M;
    for(int i=0;i<N-2;i++){
        tmp=f2;
        f2=(f1+f2)%M;
        f1=tmp;
    }
    cout << f2 << endl;
    return 0;
}
0