#K54832. Smallest Grid Size Calculation
Smallest Grid Size Calculation
Smallest Grid Size Calculation
Given two positive integers \(m\) and \(n\), determine the smallest grid dimensions (rows, columns) such that the grid can accommodate \(m\) coins. The grid is restricted to have at most \(n\) rows and \(n\) columns, and it must hold that \(1 \leq rows \leq cols \leq n\). In other words, you need to find the minimum pair \((rows, cols)\) satisfying \(rows \times cols \geq m\) while respecting \(rows \leq cols \leq n\).
For instance, when \(m = 10\) and \(n = 4\), the answer is \(3\) rows and \(4\) columns since \(3 \times 4 = 12 \geq 10\) and there is no pair with a smaller product that meets the rule.
inputFormat
The input consists of two integers, \(m\) and \(n\), separated by a space or newline. \(m\) represents the number of coins that need to fit in the grid, and \(n\) represents the maximum allowed number of rows and columns.
outputFormat
Output two integers separated by a single space: the first is the number of rows and the second is the number of columns of the minimal grid that can accommodate at least \(m\) coins.
## sample10 4
3 4