結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-09 22:27:18 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| + 106µs | |
| コード長 | 562 bytes |
| 記録 | |
| コンパイル時間 | 809 ms |
| コンパイル使用メモリ | 177,112 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-09-02 13:35:00 |
| 合計ジャッジ時間 | 1,957 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}