結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める | 
| コンテスト | |
| ユーザー |  zaichu | 
| 提出日時 | 2017-06-18 20:26:15 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 65 ms / 2,000 ms | 
| コード長 | 362 bytes | 
| コンパイル時間 | 769 ms | 
| コンパイル使用メモリ | 79,204 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-01 20:30:35 | 
| 合計ジャッジ時間 | 1,661 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 12 | 
ソースコード
#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;
}
            
            
            
        