Buildings Multi-school 2 games 1002

Source: Internet
Author: User

Buildings

Time limit:4000/2000 MS (java/others) Memory limit:131072/131072 K (java/others)
Total submission (s): 221 Accepted Submission (s): 29


Problem Descriptionyour current task was to make a ground plan for a residential building located in HZXJHS. So you must determine a-to-split the floor building with walls to make apartments in the shape of a rectangle. Each built wall must is paralled to the building ' s sides.

The floor was represented in the ground plan as a large rectangle with dimensionsnxm , where each apartment are a smaller rectangle with dimensionsaxb Located inside. For each apartment, the its dimensions can is different from each of the other. The numberaandbMust be integers.

Additionally, the apartments must completely cover the floor without one1x1 Square located on(x,y) . The apartments must isn't intersect, but they can touch.

For this example, which is a sample ofn=2,m=3,x=2,y=2 .



To prevent darkness indoors, the apartments must has windows. Therefore, each apartment must share their at least one side with the edge of the rectangle representing the floor so it's Possible to place a window.

Your boss XXY wants to minimize the maximum areas of all apartments, now it's Your turn to tell him the answer.

Inputthere is at the most10000Testcases.
For each testcase, only four space-separated integers,N,M,X,Y(1≤N,M≤8,nxm>1,1≤x≤n,1≤y≤ m) .

Outputfor each testcase, print only one interger, representing the answer.

Sample Input2 3 2 23 3 1 1

Sample Output12 HintCase 1: Can split the floor into five 1x1 Apartments. The answer is 1.Case 2: You can split the floor into three 2x1 Apartments and 1x1 Apartments. The answer is 2. If you want-to-split the floor into eight 1x1 Apartments, it'll be unacceptable B Ecause the apartment located on (2,2) can ' t has windows.

1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 intMain ()6 {7     intn,m,x,y;8      while(SCANF ("%d %d%d%d", &n,&m,&x,&y)! =EOF)9     {Ten         ints=0, k=0; One         intflg=1, MISETP; AMisetp=min (x1, Y1); -Misetp=min (misetp,n-x); -Misetp=min (misetp,m-y); thes=s+Misetp; -n=n-misetp*2, m=m-misetp*2; -x=x-misetp,y=y-Misetp; -          while(FLG) +         { -             if(n==1&& m==1&& x==1&&y==1) +S--, flg=0; As++; atn=n-2, m=m-2; -             if(n<=0|| m<=0) -                  Break; -X--, y--; -             if(x==0|| x==n+1|| y==0|| y==m+1) -             { inflg=0; -                 if((n>=2&& m>=3) || (n>=3&& m>=2)) to                 { +                     if(1<x && x<N) -                     { theK=min (x,n-x+1); *k=min (k,m); $k=k+s;Panax Notoginseng                     } -                     Else if(1<y && y<m) the                     { +K=min (y,m-y+1); Ak=min (k,n); thek=k+s; +                     } -                 } $             } $         } -         if(n>0&& m>0) -         { theS=s+min (n/2+n%2, m/2+m%2); -         }Wuyi         if(k>s) thes=K; -printf"%d\n", s); Wu     } -     return 0; About}
View Code

Buildings Multi-school 2 games 1002

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.