結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー tomokinex
提出日時 2017-06-19 12:09:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 302 bytes
コンパイル時間 552 ms
コンパイル使用メモリ 59,036 KB
実行使用メモリ 159,744 KB
最終ジャッジ日時 2024-10-02 07:38:49
合計ジャッジ時間 3,075 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include <list>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  list<int> l(n-2);
  int a = 0,b = 1;
  list<int>::iterator num = l.begin();
  for(int i=0;i<n-2;i++){
    *num = (a+b)%m;
    a = b;
    b = (int)(*num);
    ++num;
  }
  cout << b << endl;
  return 0;
}
0