結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー mannshi222mannshi222
提出日時 2022-04-29 13:20:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 371 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 67,404 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 06:23:14
合計ジャッジ時間 1,590 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>

using namespace std;

int main()
{

	int N, M;
	cin >> N >> M;
	int F1 = 0;
	int F2 = 1;
	/*
	if( N == 0 ) {
		cout << F0 << endl;
		return 0;
	}
	if( N == 1 ) {
		cout << F1 << endl;
		return 0;
	}
	*/

	int tmp;
	for( int i = 1; i < N ; i++ ) {
		tmp = F1;
		F1 = F2;
		F2 = tmp + F1;
		F1 = F1%M;
		F2 = F2%M;
	}
	cout << F1 << endl;
	return 0;
}
0