Please check my code and tell me why for the given below test case is not giving the correct solution 714


test case is :
3
1 2 3
4 5 6
6
correct solution is 714
but my answer is coming out to be 3

Hey @Bhuwan-Agrawal-2362769150606526
You didn’t multiply initial input matrix with exponentiation matrix before taking sum. You just took power matrix of co-efficients.
See this for reference https://www.geeksforgeeks.org/matrix-exponentiation/