#K44432. Smallest Perimeter Grid
Smallest Perimeter Grid
Smallest Perimeter Grid
You are given a positive integer n representing the total number of stamps. Your task is to arrange these stamps into a grid with r rows and c columns such that:
- r × c = n
- The perimeter P of the grid, given by the formula \( P = 2(r+c) \), is minimized.
For example, if n = 12, one possible grid is 3 rows by 4 columns which gives \( P = 2(3+4)=14 \). If n is a prime number, the only possible grid is 1 row and n columns.
Your solution should output three integers: the number of rows, the number of columns, and the corresponding minimum perimeter. In case of multiple valid grids, any one minimizing the perimeter is acceptable.
inputFormat
The input consists of a single integer n (\(1 \leq n \leq 10^{12}\)), which denotes the number of stamps.
The input is read from standard input (stdin).
outputFormat
Output three space-separated integers: the number of rows, the number of columns, and the minimum perimeter of the grid.
The output should be printed to standard output (stdout).
## sample12
3 4 14