bor

Binary Search

bor
Jan 21st, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6.   long long w, h, n, lo = -1, hi, mi;
  7.   scanf("%lld%lld%lld", &w, &h, &n);
  8.   hi = max(w * n, h * n);
  9.   while (lo + 1 != hi) {
  10.     mi = (lo + hi) / 2;
  11.     ((mi / w) * (mi / h) >= n ? hi : lo) = mi;
  12.   }
  13.   printf("%lld\n", hi);
  14.   return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment