国际象棋,状压dp

n,m,K=map(int,input().split())
mod=1000000007
debug=0
dp=[[[[[0 for i in range(K+1)]for i in range((1<<n)+10)]for i in range((1<<n)+10)]for i in range((1<<n)+10)]for i in range(2)]

dp[0][0][0][0][0]=1
num=[0 for i in range((1<<n)+10)]
for i in range(1<<n):
    mm=i
    ans=0
    while mm!=0:
        ans+=mm%2
        mm=mm>>1
    num[i]=ans
if debug==1:print(num)
now=1
for _ in range(m):
    for i in range(1<<n):
        
        for j in range(1<<n):
            for k in range(1<<n):
                if i&(j<<2)==0 and i&(j>>2)==0 and i&(k>>1)==0 and i&(k<<1)==0:
                    for l in range(num[i],K+1):
                        for p in range(1<<n):
                            dp[now][i][j][k][l]+=dp[now^1][j][k][p][l-num[i]]
                            dp[now][i][j][k][l]%=mod
                                                     
    now=now^1
    for i in range(1<<n):
        
        for j in range(1<<n):
            for k in range(1<<n):
                for l in range(K+1):
                    dp[now][i][j][k][l]=0
    if debug==1:print(now)
    

now=now^1
ans=0
for i in range(1<<n):
        
        for j in range(1<<n):
            for k in range(1<<n):
                ans+=dp[now][i][j][k][K]
                ans%=mod
print(ans)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值