Save Knights
Submissions: 1438   Accuracy:

37.83%

  Difficulty: Easy   Marks: 2

How many non-attacking knights K(n) can be placed on an n x n chessboard. 
Recall that a knight can attack another knight if their vertical distance on the chessboard is 2 and their horizontal distance is 1, or if their vertical distance is 1 and their horizontal distance is 2. Only one knight may be placed on each square of the chessboard.

Input:

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of a single line containing an integer  N.

Output:

Print number of places where non-attacking knights can be placed.

Constraints:
1 ≤ T ≤ 100
2 ≤ N ≤ 1000

Example:
Input:
2
5
4

Output:
13
8

** For More Input/Output Examples Use 'Expected Output' option **

Author: rajatjha


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.