結果

問題 No.604 誕生日のお小遣い
ユーザー seeking
提出日時 2019-11-16 14:15:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 935 bytes
コンパイル時間 1,213 ms
コンパイル使用メモリ 70,412 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 23:20:20
合計ジャッジ時間 2,257 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 9
権限があれば一括ダウンロードができます

ソースコード

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 = (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