結果

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

テストケース

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

ソースコード

diff #

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

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

	vector<int64_t> v = { 0,1 };
	int cnt = 2;
	while (cnt < N) {
		int64_t n = v.at(v.size() - 2) + v.at(v.size() - 1);
		v.push_back(n);
		cnt++;
	}

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