結果
問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
ユーザー |
![]() |
提出日時 | 2018-10-09 19:26:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 315 bytes |
コンパイル時間 | 1,629 ms |
コンパイル使用メモリ | 167,440 KB |
実行使用メモリ | 42,240 KB |
最終ジャッジ日時 | 2024-10-12 16:38:59 |
合計ジャッジ時間 | 2,833 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n,m; cin >> n >> m; vector<ll> f(5000001); f[0] = 0,f[1] = 1; for(int i = 2; i < n; i++){ f[i] = f[i-1] + f[i-2]; f[i] %= m; } cout << f[n-1] << endl; return 0; }