[AHOI 2009]chess 中国象棋
2018-03-17 16:48
197 查看
Description
题库链接给你一张 \(N\times M\) 的棋盘。要求每行每列最多放两个棋子,问总方案数。
\(1\leq N,M\leq 100\)
Solution
记 \(f_{i,j,k}\) 为前 \(i\) 行还剩 \(j\) 行可以放 \(1\) 个棋子, \(k\) 行放两个棋子的方案数。组合数学乱搞就好了。Code
//It is made by Awson on 2018.3.17 #include <bits/stdc++.h> #define LL long long #define dob complex<double> #define Abs(a) ((a) < 0 ? (-(a)) : (a)) #define Max(a, b) ((a) > (b) ? (a) : (b)) #define Min(a, b) ((a) < (b) ? (a) : (b)) #define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b)) #define writeln(x) (write(x), putchar('\n')) #define lowbit(x) ((x)&(-(x))) using namespace std; const int N = 100, yzh = 9999973; void read(int &x) { char ch; bool flag = 0; for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar()); for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar()); x *= 1-2*flag; } void print(unsigned LL x) {if (x > 9) print(x/10); putchar(x%10+48); } void write(unsigned LL x) {if (x < 0) putchar('-'); print(Abs(x)); } int f[N+5][N+5][N+5], n, m, C[N+5][N+5]; void work() { for (int i = 0; i <= N; i++) { C[i][0] = 1; for (int j = 1; j <= i; j++) C[i][j] = (C[i-1][j]+C[i-1][j-1])%yzh; } read(n), read(m); f[0][0][m] = 1; for (int i = 1; i <= n; i++) for (int j = 0; j <= m; j++) for (int k = 0; k <= m; k++) for (int p = 0; p <= 2; p++) for (int q = 0; q+p <= 2; q++) (f[i][j+q][k] += 1ll*f[i-1][j+p][k+q]*C[j+p][p]%yzh*C[k+q][q]%yzh) %= yzh; int ans = 0; for (int i = 0; i <= m; i++) for (int j = 0; j <= m; j++) (ans += f [i][j]) %= yzh; writeln(ans); } int main() { work(); return 0; }
相关文章推荐
- BZOJ 1801 AHOI 2009 chess 中国象棋 DP
- 【BZOJ 1801】[Ahoi2009]chess 中国象棋
- bzoj 1801: [Ahoi2009]chess 中国象棋 (组合数+DP)
- BZOJ1801: [Ahoi2009]chess 中国象棋
- [bzoj1801][Ahoi2009]chess 中国象棋
- bzoj 1801 [Ahoi2009]chess 中国象棋 dp
- 1801: [Ahoi2009]chess 中国象棋
- [BZOJ1801][Ahoi2009]chess 中国象棋
- BZOJ 1801 [Ahoi2009]chess 中国象棋 递推
- [BZOJ 1801] [Ahoi2009]chess 中国象棋 【DP】
- BZOJ1801: [Ahoi2009]chess 中国象棋
- bzoj 1801: [Ahoi2009]chess 中国象棋【dp】
- 【bzoj1801】[Ahoi2009]chess 中国象棋 dp
- 【BZOJ1801】[Ahoi2009]chess 中国象棋 DP
- 1801: [Ahoi2009]chess 中国象棋
- BZOJ 1801: [Ahoi2009]chess 中国象棋( dp )
- bzoj 1801: [Ahoi2009]chess 中国象棋
- bzoj1801[AHOI2009]CHESS中国象棋
- 1801: [Ahoi2009]chess 中国象棋
- bzoj 1801: [Ahoi2009]chess 中国象棋