https://hack.codingblocks.com/contests/c/473/758
getting the correct answer while running, but wrong answer while submitting. Please help.
FIBOSUM problem
I think you wanted to paste the link to your code
import java.util.; import java.lang.Math.;
public class Main {
static void multiply(long a[][],long b[][])
{
long mul[][]= new long[3][3];
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
mul[i][j]= 0;
for(int k=0;k<3;k++)
mul[i][j]+= a[i][k]*b[k][j];
}
}
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
a[i][j]= mul[i][j];
}
static long fib(long m[][],int n)
{
long nt[][]={{1,0,0},{1,0,1},{1,1,1}};
if(n==1)
return m[0][0]+m[2][0];
fib(m,n/2);
multiply(m,m);
if(n%2!=0)
multiply(m,nt);
return m[0][0]+m[2][0];
}
public static void main(String args[]) {
Scanner sc= new Scanner(System.in);
int T= sc.nextInt();
for(int i=0;i<T;i++)
{
long m[][]={{1,0,0},{1,0,1},{1,1,1}};
long M= sc.nextLong(); long N= sc.nextLong();int a=(int)M-2; int b=(int)N-1;long at,bt;
if(M==0) at=0;
else if(M-1==0){at=0;} else if(M-1==1){at=1;}
else
at= fib(m,a);
long u[][]={{1,0,0},{1,0,1},{1,1,1}};
if(N==0){bt=0;} else if(N==1){bt=1;}
else{
//System.out.println("calling");
bt= fib(u,b);}
// System.out.println(at+" "+bt);
// System.out.println(M+" "+N+" "+a+" "+b);
long ans= (bt-at)%((long)(Math.pow(10,9)+7));
System.out.println(ans);
}
}
}