fork(1) download
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <algorithm>
  4. #include <iostream>
  5. #include <string>
  6. #include <cassert>
  7.  
  8. using namespace std;
  9.  
  10. template <typename T> T sqr(T x) { return x * x; }
  11. template <typename T> T abs(T x) { return x < 0? -x : x; }
  12.  
  13. int main()
  14. {
  15. int k;
  16. cin >> k;
  17. while (k--)
  18. {
  19. unsigned long long w, h, n;
  20. cin >> w >> h >> n;
  21. unsigned long long l = 0, r = min(h, w), c;
  22. while (l < r)
  23. {
  24. c = (l + r + 1) / 2;
  25. unsigned long long t = h / c;
  26. if ((w / c) >= (n + t - 1) / t)
  27. l = c;
  28. else
  29. r = c - 1;
  30. }
  31. cout << l << endl;
  32. }
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 2856KB
stdin
1
4 8 5
stdout
2