Corn Fields(模板)

來源:互聯網
上載者:User

標籤: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 }

 

Corn Fields(模板)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.