Timer is Running

Recurrence Matrix
Submissions: 599   Accuracy:


  Difficulty: Medium   Marks: 4

Let's define a Series Whose recurrence formula is as follows :
C(n)= 3*C(i-1) + 4*C(i-2) + 5*C(i-3) + 6*C(i-4) 
C(0)= 2
C(1)= 0
C(2)= 1
C(3)= 7
Now based on this Series a Matrix Mi,j of size n*n is to be formed.The top left cell is(1,1) and the bottom right corner is (n,n). 
Each cell (i,j) of the Matrix contains either 1 or 0. 
If C( (i * j)^3 ) is odd, Mi,j is 1, otherwise, it's 0.
Count the total number of ones in the Matrix.

First Line Of the input will contain an integer 'T'- the number of test cases . Each of the next 'T' lines consists of an integer 'n'.-denoting the size of the matrix. 

For each test case, output a single Integer -the taste value fo the dish of size-n*n. 

Constraints : 
1 ≤ T ≤ 1000
1 ≤ n ≤ 1000

Input : 
Output : 


Example case 1
In the test case 1 : 

C(1*1*1*1*1*1)=0               C(1*1*1*2*2*2)=11424
C(2*2*2*1*1*1)=11424       C(2*2*2*2*2*2)=17408414112797894176

So, The matrix of size 2*2 will be : 
0    0    
0    0

So ,Count of ones in the Matrix is zero.

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

Contributor: Abhinav Jain
Author: iamabjain

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.