結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 RE -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 RE -
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,348 KB
testcase_16 WA -
testcase_17 WA -
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) {
	if (old + (old / A) * (B - 1) >= C) return true;
	else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search() {
	ll ng = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll ok = (ll)A / (B - 1) * C * 2 + 1; // 「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