#K35332. Maximum Non-Attacking Bishops

    ID: 25508 Type: Default 1000ms 256MiB

Maximum Non-Attacking Bishops

Maximum Non-Attacking Bishops

Given an n × n chessboard, your task is to determine the maximum number of bishops that can be placed on the board such that no two bishops can attack each other. In chess, bishops move diagonally, and two bishops attack each other if they share a diagonal.

For a chessboard of size \( n \), the solution is determined by the following observations:

  • If \( n = 1 \), the maximum number of bishops is \(1\).
  • If \( n > 1 \), the maximum number of bishops is \( 2(n-1) \), because bishops can only be placed on different diagonals.

Note: Make sure your program reads input from stdin and outputs the result to stdout.

inputFormat

The first line of input contains a single integer T representing the number of test cases. This is followed by T lines, each containing a single integer n which represents the size of the chessboard.

Sample Input:

4
1
2
3
4

outputFormat

For each test case, output a single integer on a new line, representing the maximum number of bishops that can be placed on the chessboard without any two attacking each other.

Sample Output:

1
2
4
6
## sample
4
1
2
3
4
1

2 4 6

</p>