fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. using namespace std;
  5. using namespace __gnu_pbds;
  6. typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedset;
  7. #define MO2 ios_base::sync_with_stdio(false);cin.tie(NULL);
  8. #define endl '\n'
  9. #define int long long
  10. #define elif else if
  11. #define sz(x) long(x.size())
  12. #define all(vec) vec.begin(), vec.end()
  13. const int mod = 1e9 + 7;
  14. const int dx[] = {0, -1, 0, 1, 1, -1, 1, -1};
  15. const int dy[] = {-1, 0, 1, 0, 1, 1, -1, -1};
  16.  
  17.  
  18. int n, m, k;
  19. string s, z;
  20. void dope() {}
  21.  
  22. bool can (int mid) {
  23. int seats = m / mid;
  24. int rem = m % mid;
  25. if (rem < seats - 1)
  26. rem += mid, seats--;
  27. rem -= (seats - 1);
  28. seats += rem;
  29. return seats * (mid - 1) * n >= k;
  30. }
  31.  
  32. int BS() {
  33. int l = 1, r = m, ans = -1;
  34. while (l <= r) {
  35. int mid = (l + r) / 2;
  36. if (can(mid)) {
  37. ans = mid;
  38. r = mid - 1;
  39. }
  40. else
  41. l = mid + 1;
  42. }
  43. return ans;
  44. }
  45. void solve() {
  46. cin >> n >> m >> k;
  47. cout << BS();
  48. }
  49. signed main() {
  50. MO2
  51. #if ONLINE_JUDGE || CPH
  52. #else
  53. freopen("Input.txt", "r", stdin);
  54. freopen("Output.txt", "w", stdout);
  55. #endif
  56. int nop = 1; cin >> nop;
  57. while (nop--)
  58. {
  59. solve();
  60. if (nop)
  61. cout << endl;
  62. }
  63. return 0;
  64. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
-1