1#include <iostream>2#include <cstdlib>3#include <cstring>4#include <queue>5#include <cstdio>6#include <algorithm>7#include <map>8#include <time.h>9#include <ext/pb_ds/assoc_container.hpp>Ten#include <ext/pb_ds/tree_policy.hpp> One #defineLL Long Long A - using namespacestd; - using namespace__gnu_pbds; the - - Const intMOD =12357; - + structMartix - { +LL martix[260][260]; A intRow,col; atMartix (int_row,int_col) - { -memset (Martix,0,sizeof(Martix)); -row =_row; -Col =_col; - } in voidSets (int_row,int_col) - { tomemset (Martix,0,sizeof(Martix)); +row =_row; -Col =_col; the } *Martixoperator*(ConstMartix &a)Const $ {Panax Notoginseng Martix C (row, a.col); - for(inti =0; i < row; i++) the for(intj =0; J < A.col; J + +) + for(intK =0; K < Col; k++) A { theC.MARTIX[I][J] = (C.martix[i][j] + martix[i][k] *a.martix[k][j]); + if(C.martix[i][j] >=MOD) -c.martix[i][j]%=MOD; $ } $ - returnC; - } the }; - Wuyi // the //line I do not place: new_x = x << 1, new_y = (y << 1) + 1; Number of columns +1 - //line I vertical dominoes: new_x = (x << 1) + 1, new_y = y << 1; Number of columns +1 Wu //line I horizontal dominoes: New x = (x << 2) + 3, new_y = (y << 2) + 3; Number of columns +2 - About intK; $Martix A (260,260), F (260,260); - voidDfsintXintYintCol) - { - if(col = = k) {A.martix[y][x] =1;return ;} ADFS (x<<1, (y<<1) +1, col+1); +DFS ((x<<1) +1, y <<1, col +1); the if(col +2<=k) -DFS ((x <<2)+3, (Y <<2)+3, col+2); $ } the the voidSolve () the { the intN; -scanf"%d%d",&k,&n); in if((k&1) && (n&1) ) the { theprintf"%d\n",0); About return ; the } theA.sets (1<<k,1<<k); theF.sets (1<<k,1<<k); +Dfs0,0,0); - for(inti =0; I < (1<<K); i++) theF.martix[i][i] =1;Bayi while(N >0) the { the if(N &1) -F = f*A; -A = A *A; theN >>=1; the } theprintf"%lld\n", f.martix[(1<<K)-1][ (1<<K)-1 ]); the } - the intMainvoid) the { the solve ();94 return 0; the}
Matrix Fast Power 3 k*n grid