HDU-5301 Buildings

Source: Internet
Author: User

Buildings
Time limit:4000/2000 MS (java/others) Memory limit:131072/131072 K (java/others)
Total submission (s): 387 Accepted Submission (s): 81

Problem 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 represented in the ground plan as a large rectangle with dimensions Nxm, where each apartment is a smaller re Ctangle with dimensions AXB located inside. For each apartment, the its dimensions can is different from each of the other. The number A and B must be integers.

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

For the example, this is a sample of n=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 most 10000 testcases.
For each testcase, only four space-separated integers, n,m,x,y (1≤n,m≤108,nxm>1,1≤x≤n,1≤y≤m).

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

Sample Input

2 3 2 2
3 3 1 1

Sample Output

1
2

Hint

Case 1:

You can split the floor into five 1x1 apartments. The answer is 1.

Case 2:

You can split the floor into three 2x1 apartments and both 1x1 apartments. The answer is 2.

If you want to split the floor into eight 1x1 apartments, it'll be unacceptable because the apartment located on (2,2) c An ' t has windows.

#include <cstdio>#include <algorithm>using namespace Std;intMain () {intNm,x,y; while(SCANF ("%d %d%d%d", &n, &m, &x, &y) = EOF) {if(n = =m&&x==y&& n%2==1&& N/2+1==x) {printf("%d\ n"N2);Continue; }inttx = MIN (xNx+1); tx = Max (TX, Min (m+1) /2, N-TX));intty = min (y,m-y+1); ty = max (ty, min (n +1) /2,m-Ty));intt = min (tx, Ty);printf("%d\ n", t); }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU-5301 Buildings

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.