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. bool can (int mid) {
  22. int seats = (m / mid) * mid;
  23. if (m - seats < mid - 1)
  24. seats -= mid;
  25. int rem = m - (seats + mid + 1);
  26. seats += rem;
  27. return seats * n >= k;
  28. }
  29. int BS() {
  30. int l = 1, r = m, ans = -1;
  31. while (l <= r) {
  32. int mid = (l + r) / 2;
  33. if (can (mid)) {
  34. ans = mid;
  35. r = mid - 1;
  36. }
  37. else
  38. l = mid + 1;
  39. }
  40. return ans;
  41. }
  42. void solve() {
  43. cin >> n >> m >> k;
  44. cout << BS();
  45. }
  46. signed main() {
  47. MO2
  48. #if ONLINE_JUDGE || CPH
  49. #else
  50. freopen("Input.txt", "r", stdin);
  51. freopen("Output.txt", "w", stdout);
  52. #endif
  53. int nop = 1; cin >> nop;
  54. while (nop--)
  55. {
  56. solve();
  57. if (nop)
  58. cout << endl;
  59. }
  60. return 0;
  61. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
-1