0.0 Templates for personal use
Fibonacci numbers deed Detailed method for finding a variety of direct poke here here Wallpaper (chiefs to explain in great detail)
typedef long long ll;
#define mod 1000000007
struct mat
{
ll a[2][2];
}ans;
mat multi(mat m,mat n)
{
mat temp;
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
{
temp.a[i][j]=0;
for(int k=0;k<2;k++)
{
temp.a[i][j]=(temp.a[i][j]+m.a[i][k]%mod*n.a[k][j]%mod)%mod;
}
}
return temp;
}
ll multi_pow(int b)
{
mat tem;
tem.a[0][0]=tem.a[0][1]=tem.a[1][0]=1;
tem.a[1][1]=0;
ans.a[0][0]=ans.a[1][1]=1;
ans.a[0][1]=ans.a[1][0]=0;
while(b)
{
if(b&1)
ans=multi(ans,tem);
b>>=1;
tem=multi(tem,tem);
}
return ans.a[0][1];
}