标签:stdio.h tar continue print i++ ble ace read int
1 #include <stdio.h> 2 #include <algorithm> 3 #include <string.h> 4 #include <iostream> 5 using namespace std; 6 typedef long long ll; 7 8 inline int read() 9 { 10 int x=0,f=1;char ch=getchar(); 11 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} 12 while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();} 13 return x*f; 14 } 15 16 /********************************************************************/ 17 18 const int mod = 100000000; 19 const int maxn = 15; 20 int n, m; 21 int dp[13][(1<<13)+5]; 22 int a[maxn]; 23 24 int line(int x, int y){ 25 if((a[x]&y) != y) return 0; 26 if((y&(y<<1)) != 0) return 0; 27 return 1; 28 } 29 30 int main(){ 31 int n,m; 32 while(~scanf("%d%d",&n,&m)){ 33 for(int i=1;i<=n;i++){ 34 a[i]=0; 35 for(int j=1;j<=m;j++){ 36 int t; 37 scanf("%d",&t); 38 a[i]=(a[i]<<1)+t; 39 } 40 } 41 memset(dp,0,sizeof(dp)); 42 dp[0][0] = 1; 43 for(int i = 1;i <= n;i++){ 44 for(int j=0;j<(1<<m);j++){ 45 if(line(i,j)==0)continue; 46 for(int k=0;k<(1<<m);k++){ 47 if((j&k)==0){ 48 dp[i][j]=dp[i][j]+dp[i-1][k]; 49 dp[i][j]%=mod; 50 } 51 } 52 } 53 } 54 int ans = 0; 55 for(int i = 0;i < (1<<m);i++){ 56 ans= (ans + dp[n][i] )%mod; 57 } 58 printf("%d\n",ans); 59 } 60 }
标签:stdio.h tar continue print i++ ble ace read int
原文地址:https://www.cnblogs.com/ouyang_wsgwz/p/9772330.html