結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-06-09 22:27:18 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 80 ms / 2,000 ms | 
| コード長 | 562 bytes | 
| コンパイル時間 | 1,194 ms | 
| コンパイル使用メモリ | 159,180 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-22 15:07:01 | 
| 合計ジャッジ時間 | 2,112 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 12 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,true):false;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,true):false;}
ll nextLong() {
  ll x; cin >> x; return x;
}
int main2() {
  ll N = nextLong();
  ll M = nextLong();
  ll a = 0;
  ll b = 1;
  REP(i, N-2) {
    ll c = (a + b) % M;
    a = b;
    b = c;
  }
  cout << b << endl;
  return 0;
}
int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}
            
            
            
        