結果

問題 No.604 誕生日のお小遣い
ユーザー seekingseeking
提出日時 2019-11-16 14:16:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 70,488 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-25 03:52:05
合計ジャッジ時間 1,471 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A, B, C;

bool isOK(ll old) {
	double money = (double)((old) / A * (B - 1));
	if (old + (old / A) * (B - 1) >= C||money>1000000000000000000) return true;
	else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search() {
	ll ng = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll ok = (ll)C; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* ok と ng のどちらが大きいかわからないことを考慮 */
	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;

		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main()
{
	cin >> A >> B >> C;
	cout << binary_search() << endl;
}
0