結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー IchimiyaIchimiya
提出日時 2020-07-24 18:59:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 1,456 ms
コンパイル使用メモリ 167,080 KB
実行使用メモリ 70,000 KB
最終ジャッジ日時 2023-09-07 23:36:30
合計ジャッジ時間 3,193 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 4 ms
4,384 KB
testcase_10 AC 23 ms
11,660 KB
testcase_11 AC 104 ms
69,376 KB
testcase_12 AC 103 ms
68,832 KB
testcase_13 AC 104 ms
70,000 KB
testcase_14 AC 104 ms
69,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	uint64_t N, M;
	cin >> N >> M;

	vector<uint64_t> v = { 0,1 };
	int cnt = 2;
	while (cnt < N) {
		uint64_t a, b, c;
		a = v.at(v.size() - 2);
		b = v.at(v.size() - 1);
		c = (a + b) % M;

		v.push_back(c);
		cnt++;
	}

	cout << v.at(v.size() - 1) << endl;
}
0