結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー zaichu
提出日時 2017-06-18 20:26:15
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 19 ms / 2,000 ms
+ 263µs
コード長 362 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 526 ms
コンパイル使用メモリ 98,356 KB
実行使用メモリ 9,876 KB
最終ジャッジ日時 2026-11-04 00:54:49
合計ジャッジ時間 2,423 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge7_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  int n, m;
  cin >> n >> m;
  unsigned long a = 0,b = 1,c = 1;
  for(int i = 1; i < n; i++){
    c = (a + b) % m;
    b = a;
    a = c;
  }
  cout << c << endl;
}
0