結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー Kura
提出日時 2019-08-08 12:45:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 194 bytes
コンパイル時間 1,085 ms
コンパイル使用メモリ 157,560 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-18 19:23:35
合計ジャッジ時間 1,889 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;long m;cin>>n>>m;
  long a=0;long b=1;
  long k;
  for(int i=1;i<n;i++){
    k=a+b;
    k%=m;
    b=a;a=k;
  }
  cout<<k<<endl;
}
0