fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. ll n, m, k;
  5. bool check(ll x)
  6. {
  7. ll cnt = 0;
  8. for(int i = 1; i <= n; i++)
  9. {
  10. cnt+=min(m, x / i);
  11. }
  12. return cnt >= k;
  13. }
  14. int main()
  15. {
  16. ios_base::sync_with_stdio(0);
  17. cin.tie(0);
  18. freopen("cau4.INP", "r", stdin);
  19. freopen("cau4.OUT", "w", stdout);
  20. cin >> n >> m >> k;
  21. ll l = 1, r = n * m, res = 0;
  22. while(l <= r)
  23. {
  24. ll mid = (l + r) / 2;
  25. if(check(mid))
  26. {
  27. res = mid;
  28. r = mid - 1;
  29. }
  30. else
  31. l = mid + 1;
  32. }
  33. cout << res;
  34. }
  35.  
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
Standard output is empty