Ultraviolet A -- 103 Stacking Boxes + dp

Source: Internet
Author: User

Ultraviolet A -- 103 Stacking Boxes + dp

Question:

In fact, it is to extend the rectangle nesting to n-dimensional, but it is stipulated that the n-dimensional ry can be distorted at will.

Ideas:

It is based on the idea of rectangular nesting, but when determining whether it can be nested, we can directly sort the order to determine (because it can be arbitrarily distorted ). There is also the need to print the entire sequence. here we can use the idea in the book to print it recursively.


The Code is as follows:


#include
 
  #include
  
   #include
   
    #includeusing namespace std;int st[50][15];int map[50][50],d[50],n,m;int dp(int i){    if(d[i]>0) return d[i];    d[i]=1;    for(int j=0;j
    
     =b[i])           return 0;    return 1;}void Init(){    memset(d,0,sizeof(d));    memset(map,0,sizeof(map));}int main(){    int i,j;    while(scanf("%d%d",&n,&m)!=EOF)    {        for(i=0;i
     
      ans)            {                ans=t;                k=i;            }        }        printf("%d\n",ans);        print(k);        printf("\n");    }  return 0;}
     
    
   
  
 



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.