#include <cstdio> #include <iostream> using namespace std; #define mod 1000000007 const int MAX = 3; struct Matrix{ int m[MAX][MAX]; }I; void init (int n){ for(int i=0 ; i<n ; i++){ I.m[i][i]=1; } } Matrix matrixmul(Matrix a,Matrix b) { int i,j,k; Matrix c; for (i = 0 ; i < MAX; i++) for (j = 0; j < MAX;j++) { c.m[i][j] = 0; for (k = 0; k < MAX; k++) c.m[i][j] += (a.m[i][k] * b.m[k][j])%mod; c.m[i][j] %= mod; } return c; } Matrix quickpow(Matrix m,long long n) { Matrix b = I; while (n >= 1) { if (n & 1) b = matrixmul(b,m); n = n >> 1; m = matrixmul(m,m); } return b; } int main(){ init(3); return 0; }
|