結果
問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
ユーザー | sigmani |
提出日時 | 2022-02-10 17:35:39 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 455 bytes |
コンパイル時間 | 998 ms |
コンパイル使用メモリ | 90,904 KB |
実行使用メモリ | 42,712 KB |
最終ジャッジ日時 | 2023-09-08 06:55:09 |
合計ジャッジ時間 | 1,884 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,384 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 5 ms
4,388 KB |
testcase_10 | AC | 19 ms
11,576 KB |
testcase_11 | AC | 89 ms
42,396 KB |
testcase_12 | AC | 89 ms
42,424 KB |
testcase_13 | AC | 88 ms
42,388 KB |
testcase_14 | AC | 89 ms
42,712 KB |
ソースコード
#include<iostream> #include<algorithm> #include<string> #include<math.h> #include<bitset> #include <vector> #include<bitset> #include <iomanip> #include <map> #include <set> #include <stack> #include <deque> #include <climits> #include <queue> using namespace std; int main() { long long N, M; cin >> N >> M; long long A[5100000]; A[1] = 0; A[2] = 1; for (int i = 3; i <= N; i++) { A[i] = (A[i - 1] + A[i - 2]) % M; } cout << A[N] << endl; }