#C8521. Count Black Squares on a Chessboard
Count Black Squares on a Chessboard
Count Black Squares on a Chessboard
Given a chessboard with n rows and n columns, the squares are colored in an alternating pattern starting with a white square in the top-left corner. Your task is to compute the number of black squares on the board. Note that when the total number of squares, \(n^2\), is odd, the number of black squares is \(\lfloor\frac{n^2}{2}\rfloor\). When \(n^2\) is even, exactly half of the squares are black.
Input Example: For an input of 4
, the chessboard is 4x4 and the number of black squares is 8
.
Note: You should read the input from stdin
and output the result to stdout
.
inputFormat
The input consists of a single integer n
(1 ≤ n ≤ 10^9), representing the size of the chessboard.
The input is provided via stdin
.
outputFormat
Output a single integer, the number of black squares on the n x n chessboard.
The output should be written to stdout
.
1
0