学习位运算
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, dp[15][4105], a[15], uu, ans;
const int mod=100000000;
int main(){
cin>>m>>n;
for(int i=1; i<=m; i++)
for(int j=1; j<=n; j++){
scanf("%d", &uu);
a[i] |= uu << (j-1);
}
for(int i=0; i<(1<<n); i++)
if((i|a[1])==a[1] && (i&(i<<1))==0)
dp[1][i] = 1;
for(int i=2; i<=m; i++)
for(int j=0; j<(1<<n); j++)
if((j|a[i])==a[i] && (j&(j<<1))==0)
for(int k=0; k<(1<<n); k++)
if((j&k)==0)
dp[i][j] = (dp[i][j] + dp[i-1][k]) % mod;
for(int i=0; i<(1<<n); i++)
ans = (ans + dp[m][i]) % mod;
cout<<ans<<endl;
return 0;
}
原文地址:https://www.cnblogs.com/poorpool/p/8277394.html
时间: 2024-11-02 12:53:23