結果
| 問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
| コンテスト | |
| ユーザー |
e869120
|
| 提出日時 | 2017-06-09 22:22:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 99 ms / 2,000 ms |
| コード長 | 335 bytes |
| コンパイル時間 | 651 ms |
| コンパイル使用メモリ | 78,248 KB |
| 実行使用メモリ | 48,476 KB |
| 最終ジャッジ日時 | 2024-09-22 14:37:45 |
| 合計ジャッジ時間 | 2,799 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
using namespace std;
long long dp[6000000], n, m;
int main() {
cin >> n >> m;
dp[1] = 0; dp[2] = 1;
for (int i = 3; i < 5500000; i++)dp[i] = (dp[i - 1] + dp[i - 2]) % m;
cout << dp[n] << endl;
return 0;
}
e869120