結果
問題 |
No.604 誕生日のお小遣い
|
ユーザー |
![]() |
提出日時 | 2019-11-16 14:08:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 893 bytes |
コンパイル時間 | 553 ms |
コンパイル使用メモリ | 70,328 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 23:20:22 |
合計ジャッジ時間 | 1,998 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 7 WA * 12 RE * 2 |
ソースコード
#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; }