#C4638. Maximizing Non-Attacking Rooks
Maximizing Non-Attacking Rooks
Maximizing Non-Attacking Rooks
You are given an integer n representing the size of an n × n chessboard. Your goal is to determine the maximum number of rooks that can be placed on the board so that no two rooks attack each other.
Recall that in chess, a rook can move any number of squares vertically or horizontally. Therefore, if two rooks are on the same row or the same column, they will be attacking each other. This implies that at most one rook can be placed per row and per column.
Mathematically, the maximum number of non-attacking rooks that can be placed on an n × n chessboard is:
$$\text{Result} = n$$Find and output the maximum number of non-attacking rooks.
inputFormat
The input consists of a single line that contains a single integer n (1 ≤ n ≤ 10^8
), representing the size of the chessboard.
outputFormat
Output a single integer representing the maximum number of non-attacking rooks that can be placed on the board.
## sample1
1
</p>