結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
| コンテスト | |
| ユーザー |
alorie10
|
| 提出日時 | 2021-06-18 02:09:58 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 224 ms / 2,000 ms |
| コード長 | 394 bytes |
| 記録 | |
| コンパイル時間 | 1,461 ms |
| コンパイル使用メモリ | 183,868 KB |
| 実行使用メモリ | 199,040 KB |
| 最終ジャッジ日時 | 2026-03-05 02:13:07 |
| 合計ジャッジ時間 | 3,019 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
ll n,m,mem[5000001];
string s[30];
vector<ll> v;
ll fib(ll a,ll b){
if(mem[a])return mem[a];
if(a==1)return 0;
if(a==2)return 1;
return mem[a]=(fib(a-1,b)+fib(a-2,b))%b;
}
int main(void){
cin>>n>>m;
cout<<fib(n,m)<<endl;
}
alorie10