Guest User

491C

a guest
Jun 23rd, 2018
2,812
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. bool check(long long k, long long n) {
  6.     long long sum = 0;
  7.     long long cur = n;
  8.     while (cur > 0) {
  9.         long long o = min(cur, k);
  10.         sum += o;
  11.         cur -= o;
  12.         cur -= cur / 10;
  13.     }
  14.     return sum * 2 >= n;
  15. }
  16.  
  17. int main() {
  18.     long long n;
  19.     cin >> n;
  20.  
  21.     long long l = 1, r = n;
  22.     long long ans = r;
  23.     while (l <= r) {
  24.         long long k = (l + r) / 2;
  25.         if (check(k, n)) {
  26.             ans = k;
  27.             r = k - 1;
  28.         }
  29.         else
  30.             l = k + 1;
  31.     }
  32.  
  33.     cout << ans << endl;
  34. }
RAW Paste Data