#include #include #include #include using namespace std; const int maxn=105; const int K=4; const int MOD=100000; struct mat { int a[maxn][maxn]; mat() { memset(a,0,sizeof(a)); } }; int root,L; mat mul(mat A,mat B)//矩阵乘法 { mat C; for(int i=0;i0) { if(n&1) ans=mul(ans,A); A=mul(A,A); n>>=1; } return ans; } struct ACAutomata { int next[maxn][K],fail[maxn],end[maxn],id[maxn]; int idx(char ch)//转化数字 { switch(ch) { case 'A':return 0; case 'C':return 1; case 'T':return 2; case 'G':return 3; } return -1; } int newNode()//新建结点 { for(int i=0;i Q; fail[root]=root; for(int i=0;i