#include <iostream>
using namespace std;
class Solution {
public:
int findKthNumber(int m, int n, int k) {
int l = 1, r = m * n + 1;
while(l < r){
int mid = (l + r) / 2;
int rank = get(mid, m, n);
if(rank < k) l = mid + 1;
else r = mid;
}
return l;
}
private:
int get(int x, int m, int n){
int res = 0;
for(int i = 1; i <= m; i ++)
res += min(x / i, n);
return res;
}
};
int main() {
cout << Solution().findKthNumber(3, 3, 5) << endl;
cout << Solution().findKthNumber(2, 3, 6) << endl;
cout << Solution().findKthNumber(42, 34, 401) << endl;
return 0;
}