Consider the m by n multiplication table whose cell in row i and column j (both 1-indexed) holds the product i * j. List all m * n cell values in non-decreasing order, keeping duplicates. Find the k-th value in that list.
A single line with three integers m, n, and k.
A single integer: the k-th smallest cell value (counting multiplicity).
Example 1
Input
3 3 5
Expected
3
Explanation
The 3-by-3 table values sorted are 1,2,2,3,3,4,6,6,9, and the 5th of these is 3.
Example 2
Input
2 3 4
Expected
3
Explanation
The 2-by-3 table values sorted are 1,2,2,3,4,6, and the 4th is 3.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →