看到这题还没有吊打标程的BM题解,神larryzhong(即hellomath)连连怒斥。
larryzhong说这是BM板子,没什么讲的意义,不会的自行百度。
下面贴上larryzhong吊打标程的代码:
#include <bits/stdc++.h>
using namespace std;
const int P = 10007;
int n, m, tot, f[2][210][210];
char s[210];
struct mat {
unsigned long long a[300][300]; } A, B;
mat operator * (const mat &A, const mat &B) {
static mat C; memset(C.a, 0, sizeof(C.a));
for (int i = 1; i <= tot; i++) {
for (int j = 1; j <= tot; j++) if (A.a[i][j]) {
for (int k = 1; k <= tot; k++) {
C.a[i][k] += A.a[i][j] * B.a[j][k];
}
}
}
for (int i = 1; i <= tot; i++) {
for (int j = 1; j <= tot; j++) {
C.a[i][j] %= P;
}
}
return C;
}
int qp(int x, int y) {
int z = 1;