Mondrian's dream

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=12,M=1<<N;
long long f[N][M];
bool st[M];

int main(void){
    int n,m;
    while(cin>>n>>m,n||m){
       
        for(int i=0;i<1<<n;i++){
            st[i]=true;
            int cnt=0;
            for(int j=0;j<n;j++){
                if(i>>j&1){
                    if(cnt&1)st[i]=false;
                    cnt=0;
                    
                }else cnt++;
            }
            if(cnt&1)st[i]=false;
        }
        memset(f,0,sizeof f);
        f[0][0]=1;
         For ( int I = . 1 ; I <= m; I ++ )
             for ( int J = 0 ; J < . 1 << n-; J ++ )
                 for ( int K = 0 ; K < . 1 << n-; K ++ ) {
                     IF ( (j & k) == 0 && ST [j | k]) // j protruding portion to k protruding portion does not conflict and there are an even number of spaces between the j-th portion and the k parts 
                        f [i] [j] + F = [I- . 1 ] [K]; 
                } 
        COUT << F [m] [ 0 ] << endl; 
    } 
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/programyang/p/11246102.html