#P6337. Maximizing Pieces by Parallel Cuts
Maximizing Pieces by Parallel Cuts
Maximizing Pieces by Parallel Cuts
Given a rectangular board, you are allowed to make exactly n straight cuts. Each cut must be parallel to one of the sides of the board. Determine the maximum number of pieces that can be obtained by making these cuts.
If you make a vertical cuts and b horizontal cuts such that a+b=n, then the board is divided into (a+1)(b+1) pieces. It can be proven that the maximum number of pieces is achieved when a = \(\lfloor n/2 \rfloor\) and b = n - \(\lfloor n/2 \rfloor\). Thus, the maximum pieces is given by:
$$ (\lfloor n/2 \rfloor + 1) \times (n - \lfloor n/2 \rfloor + 1) $$
inputFormat
The input consists of a single integer n (0 ≤ n ≤ 109), representing the number of cuts made on the board.
outputFormat
Output the maximum number of pieces the board can be divided into after making n cuts.
sample
0
1