Jeny love Sweets so much. Now she is at famous restaurant and wants to eat M pieces of a particular sweet. Cost of nth sweet can only be determined by the determinant of matrix of order n x n, where n = 1 to M. The (i, j)th term of matrix is given as:
A[i][j]= minimum(i, j) *(-1)((i-1)*n + (j-1)).
Matrix indexes starts with 1. The task is to find the cost of M sweets.
Input: The First line of input contains a integer T, denoting the total number of test cases. Then T test cases follow. Each test case consists of a single line conataining an integer M denoting the number of Sweets.
Output: Print the desired output corresponding to each test case in a separate line.
MAtrix of 1*1 is: |1|
Matrix of 2*2 is: |1 -1|
Determinant of matrix 1x1 = 1
Determinant of matrix 2x2= -1
Cost of 1 sweet = 1
Cost of 2 sweets = Cost of 1st sweet + Cost of 2nd sweet = 1 + -1 = 0
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.