結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める | 
| コンテスト | |
| ユーザー |  yamachaso | 
| 提出日時 | 2022-08-03 16:10:36 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 81 ms / 2,000 ms | 
| コード長 | 1,264 bytes | 
| コンパイル時間 | 3,783 ms | 
| コンパイル使用メモリ | 230,208 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-13 09:28:23 | 
| 合計ジャッジ時間 | 4,835 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 12 | 
ソースコード
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all> // g++ main.cpp -std=c++17 -I .
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
template<class T> void my_printv(vector<T> v,bool endline = true){
  if(!v.empty()){ for(size_t i{}; i<v.size()-1; i++) cerr<<v[i]<<' '; cerr<<v.back(); }
  if(endline) cerr<<endl;
}
using ll = long long;
const int inf = INT_MAX / 2; const ll INF = 1LL << 60;
const ll MOD = 1000000007;
// const int MOD = 998244353;
// cout << fixed << setprecision(15) << ans << endl;
// using mint = modint1000000007;
using mint = modint998244353;
// using mint = modint;
////////////////////////////////////////////////////////////////////////////////////////////
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vector<ll> dp(2);
  dp[0] = 0, dp[1] = 1;
  rep(i, n-1) {
    ll t = dp[1];
    dp[1] = (dp[0] + dp[1])%m;
    dp[0] = t;
  }
  cout << dp[0] << endl;
}
            
            
            
        