結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー sigmanisigmani
提出日時 2022-02-10 17:34:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 454 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 91,000 KB
実行使用メモリ 6,200 KB
最終ジャッジ日時 2023-09-08 06:53:22
合計ジャッジ時間 2,650 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
5,316 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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[350000];
	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;

}
0