题意:在N行M列的棋盘上,放若干个炮可以是0个,使得没有任何一个炮可以攻击另一个炮。 请问有多少种放置方法,中国像棋中炮的行走方式大家应该很清楚吧.
题解:dp[i][j][k]表示到了第i行,有j列含1个炮,k列含2个炮,转移随便搞就行了
/**************************************************************
Problem: 1801
User: walfy
Language: C++
Result: Accepted
Time:356 ms
Memory:11784 kb
****************************************************************/
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 9999973
#define ld long double
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
//#define cd complex<double>
#define ull unsigned long long
#define base 1000000000000000000
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
template<typename T>
inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>
inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c,b>>=1;}return ans;}
using namespace std;
const double eps=1e-8;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=100+10,maxn=3000000+10,inf=0x3f3f3f3f;
ll c[N][N],dp[N][N][N];
void init()
{
for(int i=0;i<N;i++)
{
c[i][0]=c[i][i]=1;
for(int j=1;j<i;j++)
c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
}
}
int main()
{
init();
int n,m;scanf("%d%d",&n,&m);
dp[0][0][0]=1;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=m;j++)
{
for(int k=0;k<=m;k++)
{
if(j+k>m)continue;
int zero=m-j-k;
add(dp[i][j][k],dp[i-1][j][k]);
if(j+k+1<=m)add(dp[i][j+1][k],dp[i-1][j][k]*c[zero][1]%mod);
if(j>=1)add(dp[i][j-1][k+1],dp[i-1][j][k]*c[j][1]%mod);
if(j+k+2<=m)add(dp[i][j+2][k],dp[i-1][j][k]*c[zero][2]%mod);
if(j>=2)add(dp[i][j-2][k+2],dp[i-1][j][k]*c[j][2]%mod);
if(j>=1&&j+k+1<=m)add(dp[i][j][k+1],dp[i-1][j][k]*c[zero][1]%mod*c[j][1]%mod);
}
}
}
ll ans=0;
for(int i=0;i<=m;i++)
{
for(int j=0;j<=m;j++)
{
if(i+j>m)continue;
add(ans,dp[n][i][j]);
}
}
printf("%lld
",ans);
return 0;
}
/********************
********************/