結果
| 問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
| コンテスト | |
| ユーザー |
Ilag
|
| 提出日時 | 2020-09-08 23:36:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 79 ms / 2,000 ms |
| コード長 | 429 bytes |
| コンパイル時間 | 1,428 ms |
| コンパイル使用メモリ | 165,580 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 13:18:52 |
| 合計ジャッジ時間 | 2,337 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,m;
cin>>n>>m;
ll fib[2];
fib[0]=1,fib[1]=0;
for(int i=3;i<=n;i++){
fib[i&1]+=fib[(i-1)&1];
fib[i&1]%=m;
}
cout<<fib[n&1]<<endl;
}
Ilag