2015 Multi-school race second game 1002 (Hdu 5301)

Source: Internet
Author: User

Description

Your 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.

Input

There 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) .

Output

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

Sample Input

2 3 2 23 3 1 1

Sample Output

12

Hint

Case 1:
1x1   Apartments. The answer is 1. Case 2:
2x1    1x1   Apartments. The answer is 2.
1x1 
Comments in the code.
#include <iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespacestd;intN,m,x,y,ans;intMain () {//freopen ("In.txt", "R", stdin);     while(~SCANF ("%d%d%d%d", &n, &m, &x, &y)) {        if(n>m) Swap (n,m), swap (x, y);//Unified ProcessingAns= (n+1)/2;//half of the short side        intT1=max (x1, n-x), T2=min (y,m-y+1); if(ans<t2&&x-1!=n-x) ans=min (t1,t2); //if x-1!=n-x, then T1>=ans, and if ans<t2 at this point, indicates that the missing part of the portrait cannot be placed in a horizontal position instead//therefore, instead of T1, you can complement the vertical placement of the lack, replaced by T2, you can be placed in a horizontal alternative portrait, whichever is smaller        if(n==m&&x==y&& (x*2-1==n)) ans= (n1)/2; //if it is in the middle, special judgment is required. printf"%d\n", ans); }    return 0;}
View Code

2015 Multi-school race second game 1002 (Hdu 5301)

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.