#include<stdio.h>
#define Max 2
#define kmod 7
typedef struct Matrix{
int M[Max][Max];
}Matrix;
Matrix P; //等比矩阵,在main中修正;
Matrix I={1,0,
0,1}; //单位矩阵,需根据Max扩大;
Matrix Matrixmul(Matrix a,Matrix b){ //矩阵乘法;
Matrix ret;
int i,j,k;
for(i=0;i<Max;i++)
for(j=0;j<Max;j++)
{
ret.M[i][j]=0;
for(k=0;k<Max;k++)
ret.M[i][j]+=(a.M[i][k]*b.M[k][j])%kmod;
ret.M[i][j]%=kmod;
}
return ret;
}
Matrix quickpow(__int64 n){ // 快速幂;
Matrix m=P,b=I;
while(n>0){
if(n&1)
b=Matrixmul(b,m);
n>>=1;
m=Matrixmul(m,m);
}
return b;
}