Poj 2411 Mondriaan & amp; #39; s Dream (pressure DP)

Source: Internet
Author: User

Poj 2411 Mondriaan & #39; s Dream (pressure DP)

Mondriaan's Dream
Time Limit:3000 MS Memory Limit:65536 K
Total Submissions:12232 Accepted:7142

Description

Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. one night, after producing the drawings in his 'toilet series' (where he had to use his toilet paper to draw on, for all of his paper was filled with squares and rectangles ), he dreamt of filling a large rectangle with small rectangles of width 2 and height 1 in varying ways.

Expert as he was in this material, he saw at a glance that he "ll need a computer to calculate the number of ways to fill the large rectangle whose dimensions were integer values, as well. help him, so that his dream won't turn into a nightmare!

Input

The input contains several test cases. each test case is made up of two integer numbers: the height h and the width w of the large rectangle. input is terminated by h = w = 0. otherwise, 1 <= h, w <= 11.

Output

For each test case, output the number of different ways the given rectangle can be filled with small rectangles of size 2 times 1. Assume the given large rectangle is Z limit? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> keys" pst "> Sample Input

1 21 31 42 22 32 42 114 110 0

Sample Output

10123514451205

Source

Ulm Local 2000



The idea is the same as (in the previous article) SGU 131. The key to this type of question is to learn how to enumerate the status and transfer the status.


#include 
 
  #include 
  
   #include 
   
    #define LL long longusing namespace std;const int N=12;LL dp[N][1<
    
     m)    {        if(!b1 && !b2)  dp[x][s1]+=dp[x-1][s2];        return ;    }    if(!b1 && !b2)  dfs(x,y+1,s1*2+1,s2*2,0,0);    if(!b1)         dfs(x,y+1,s1*2+1,s2*2+1-b2,1,0);    dfs(x,y+1,s1*2+b1,s2*2+1-b2,0,0);}void initial(){    len=1<
     
      

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.