Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. typedef unsigned int uint;
  6.  
  7. uint n, a, b;
  8.  
  9. uint binarySearch()
  10. {
  11. uint x = a + b;
  12.  
  13. while (x > 1)
  14. {
  15. x = (x + 1) / 2;
  16. //cout << x << endl;
  17. if (a / x + b / x >= n) {
  18. if (a < x) return a;
  19. return x;
  20. }
  21. }
  22. return x;
  23. }
  24.  
  25. int main() {
  26.  
  27. ios::sync_with_stdio(false);
  28.  
  29. cin >> n >> a >> b;
  30.  
  31. if (a > b)
  32. swap(a, b);
  33.  
  34. cout << binarySearch();
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement