#C11099. Tulip Grid Arrangement
Tulip Grid Arrangement
Tulip Grid Arrangement
You are given an integer n representing the number of tulips to be planted. Your task is to determine the grid dimensions (number of rows and columns) for planting these tulips such that the grid is as close to a square as possible. In other words, you should choose a factorization of n into two integers r and c (with r * c = n) that minimizes the absolute difference |r - c|. If there are multiple solutions with the same difference, choose the one with the smaller number of rows. Note that if n is a prime number, then the only valid grid is (1, n)
.
Constraints: 1 ≤ n ≤ 109
inputFormat
The input consists of a single line containing one integer n — the number of tulips to be planted.
outputFormat
Output two space-separated integers representing the number of rows and columns of the grid, respectively.
## sample9
3 3
</p>