結果

問題 No.320 眠れない夜に
ユーザー snrnsidysnrnsidy
提出日時 2021-08-31 10:22:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 548 bytes
コンパイル時間 1,981 ms
コンパイル使用メモリ 197,180 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 14:09:19
合計ジャッジ時間 3,696 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

unsigned long long int f[81];


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	f[1] = 1;
	f[2] = 1;
	for (int i = 3; i <= 80; i++)
	{
		f[i] = f[i - 1] + f[i - 2];
	}

	int n;
	unsigned long long int m;

	cin >> n >> m;
	long long int diff = f[n];
	diff -= m;

	if (diff < 0)
	{
		cout << -1 << '\n';
		return 0;
	}
	int res = 0;

	for (int i = 80; i >= 1; i--)
	{
		if (diff >= f[i])
		{
			diff -= f[i];
			res++;
		}
	}

	if (diff > 0) res = -1;

	cout << res << '\n';

	return 0;
}
0