Time Limit:10 Sec Memory limit:64 MB Description on the N-row m-column board, a number of guns can be 0, so that no cannon can attack another cannon. I ask how many kinds of placement methods, the Chinese like chess gun in the way of walking everyone should be very clear. The input row contains two integer n,m separated by a space. Output output of all scheme numbers, due to the large value, outputs its mod 9999973Sample Input1 3
Sample Output7
HINT
In addition to the case where all 3 compartments are filled with guns, everything else is possible.
100% of the data n,m not more than 100
In 50% of the data, N,m has at least one number not exceeding 8
30% of the data, n,m are not more than 6
Source
Day2
With F[i][j][k] in the first I line has J Line put a gun, K line put two cannon.
So there are 6 kinds of shifts in this problem.
1. Do not put
2. Put one in one of the missed columns
3. Put one in a column that has been put in one
4. Put two in a row that has been spared
5. Put one in each of the two columns that have been spared
6. Put one in each of the missed and already placed columns
#include <cstdio>typedefLong Longll;Const intMod=9999973;intf[ the][ the][ the];intMain () {intn,m,ans=0; scanf ("%d%d",&n,&m); f[0][0][0]=1; for(intI=1; i<=n;i++) for(intj=0; j<=m;j++) for(intk=0; k+j<=m;k++) {F[i][j][k]=f[i-1][j][k]; if(j) f[i][j][k]+= (LL) (m-j-k+1) *f[i-1][j-1][k]%mod,f[i][j][k]%=MoD; if(k) f[i][j][k]+= ((LL) (j+1) *f[i-1][j+1][k-1]+ (LL) (m-j-k+1) *j%mod*f[i-1][j][k-1])%mod,f[i][j][k]%=MoD; if(k>1) f[i][j][k]+= (LL) (j+2) * (j+1)/2%mod*f[i-1][j+2][k-2])%mod,f[i][j][k]%=MoD; if(j>1) f[i][j][k]+= (LL) (m-j+2-k) * (m-j+1-K)/2%mod*f[i-1][j-2][k]%mod,f[i][j][k]%=MoD; if(i==n) ans+=f[i][j][k],ans%=MoD; } printf ("%d", ans); return 0;}
Bzoj1801:[ahoi2009]chess Chinese Chess