Problem Statement | |||||||||||||
On a piece of paper you draw a rectangular grid whose outer edges coincide with the edges of the paper. Every grid cell is exactly 1 unit by 1 unit. You can use scissors to cut out groups of cells along grid lines. The length of a cut is given as the number of units that the scissors need to travel along grid lines. Given that the grid has dimensions width units by height units return the minimum length of a cut that cuts out exactly n cells from the piece of paper. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | width will be between 1 and 1000 inclusive. | ||||||||||||
- | height will be between 1 and 1000 inclusive. | ||||||||||||
- | n will be between 1 and width*height inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|