結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
| コンテスト | |
| ユーザー |
chacoder1
|
| 提出日時 | 2021-01-31 10:59:36 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 167 ms / 2,000 ms |
| コード長 | 320 bytes |
| 記録 | |
| コンパイル時間 | 1,161 ms |
| コンパイル使用メモリ | 208,616 KB |
| 実行使用メモリ | 199,040 KB |
| 最終ジャッジ日時 | 2026-06-17 12:05:09 |
| 合計ジャッジ時間 | 2,827 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
ll res[5000010];
ll fiv(ll x,ll y){
if(res[x] != 0) return res[x];
if(x==1) return 0;
if(x==2) return 1;
res[x]=(fiv(x-1,y)+fiv(x-2,y))%y;
return res[x];
}
int main(){
ll n,m;
cin>>n>>m;
cout<<fiv(n,m)<<endl;
return 0;
}
chacoder1