結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー toma_tanichaeltoma_tanichael
提出日時 2020-08-23 09:18:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 559 bytes
コンパイル時間 1,357 ms
コンパイル使用メモリ 162,764 KB
実行使用メモリ 23,296 KB
最終ジャッジ日時 2024-04-23 17:29:29
合計ジャッジ時間 1,950 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int N, M;
int a[5000001];


int main() {
  cin >> N >> M;
  a[1] = 0;
  a[2] = 1;
  rep(i, N) {
    a[i+3] = a[i+2] + a[i+1];
  }
  int ans = a[N] % M;
  cout << ans << endl;
  return 0;
}
0