Dp.
If the pressure DP, you can only get 50 points. and positive solution is both better than the shape of the pressure to write, but also the positive solution.
F[I][J][K] Indicates that there is a J column in line I has a chess piece, there are two pieces of k column, and then the DP transfer is good (the equation is too difficult to write, do not write ...) )
100*100*mod may explode int, so a long long is used.
#include <cstdio>#include<algorithm>#include<cstring>using namespaceStd;typedefLong LongLL;Const intMAXN = -+Ten;ConstLL mod =9999973; LL F[MAXN][MAXN][MAXN]; LL N,m,res;intMain () {scanf ("%lld%lld",&n,&m); Memset (F,0,sizeof(f)); f[0][0][0]=1; for(LL i=1; i<=n;i++) { for(LL j=0; j<=m;j++) for(LL k=0; k<=m;k++)if(j+k<=m) {LL&h =F[i][j][k]; H= (h+f[i-1][J][K])%MoD; if(j>=1) h= (h+f[i-1][j-1][k]* (m-j-k+1))%MoD; if(k>=1) h= (h+f[i-1][j+1][k-1]* (j+1))%MoD; if(j>=2) h= (h+f[i-1][j-2][k]* ((m-j-k+1) * (m-j-k+2)/2))%MoD; if(k>=1) h= (h+f[i-1][j][k-1]* (m-j-k+1) *j)%MoD; if(k>=2) h= (h+f[i-1][j+2][k-2]* ((j+2) * (j+1)/2))%MoD; }} Res=0; for(intI=0; i<=m;i++) for(intj=0; j<=m;j++)if(i+j<=m) res= (Res+f[n][i][j])%MoD; printf ("%lld\n", RES); return 0;}
bzoj1801: [ahoi2009]chess Chinese chess