#K85917. Minimum Number of Cameras
Minimum Number of Cameras
Minimum Number of Cameras
You are given an integer n
representing the size of a grid, that is, an n x n
grid. Each cell in the grid requires surveillance by strategically placed cameras. The problem is to determine the minimum number of cameras needed to cover all street segments in the grid according to the following rules:
- If
n
is 2 or 3, then only 1 camera is needed. - If
n
is even andn \geq 4
, then the answer is given by the formula: $$\left(\frac{n}{2}\right)^2$$. - If
n
is odd andn \geq 5
, then the answer is given by the formula: $$\left(\left\lfloor\frac{n}{2}\right\rfloor+1\right)^2$$.
Your task is to read the value of n
from standard input and output the corresponding minimum number of cameras to standard output.
inputFormat
The input consists of a single integer n
(n \ge 2
), which denotes the dimensions of the grid.
outputFormat
Output a single integer representing the minimum number of cameras required to cover the grid based on the conditions provided.
## sample2
1