2015杭电多校第二场

Buildings

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1622    Accepted Submission(s): 460

Problem Description

Your
current task is to make a ground plan for a residential building
located in HZXJHS. So you must determine a way to split the floor
building with walls to make apartments in the shape of a rectangle. Each
built wall must be paralled to the building‘s sides.

The floor is represented in the ground plan as a large rectangle with dimensions n×m, where each apartment is a smaller rectangle with dimensions a×b located inside. For each apartment, its dimensions can be different from each other. The number a and b must be integers.

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

For this example, this is a sample of n=2,m=3,x=2,y=2.

To
prevent darkness indoors, the apartments must have windows. Therefore,
each apartment must share its at least one side with the edge of the
rectangle representing the floor so it is 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 are at most 10000 testcases.
For each testcase, only four space-separated integers, n,m,x,y(1≤n,m≤108,n×m>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 1×1 apartments. The answer is 1.

Case 2:
You can split the floor into three 2×1 apartments and two 1×1 apartments. The answer is 2.
If you want to split the floor into eight 1×1 apartments, it will be unacceptable because the apartment located on (2,2) can‘t have windows.

Source

2015 Multi-University Training Contest 2

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int  main()
{
    //fropen("in","r",stdin);
   // fropen("out","w",stdin);
    int n,m,a,b;

    while(scanf("%d%d%d%d",&n,&m,&a,&b)!=EOF)
    {
        int d,f,h;
        int v1,v2,v3,v4,k,l;
        v1=n/2+n%2;
        f=m/2+m%2;
        h=min(v1,f);
        d=max(v1,f);
        if(n==m&&n%2==1&&m%2==1&&h==min(a,b)&&d==max(a,b))
        {
            printf("%d\n",h-1);
            continue;
        }
        if(h==v1)
        {
            k=max(a-1,n-a);

            v2=min(k,min(m-b+1,b));
        }
        else
        {
            k=max(b-1,m-b);

            v2=min(k,min(n-a+1,a));
        }
        v2=max(v2,h);
        printf("%d\n",v2);
    }
    return 0;
}

时间: 2024-11-10 08:42:35

2015杭电多校第二场的相关文章

2019年杭电多校第二场 1002题Beauty Of Unimodal Sequence(LIS+单调栈)

题目链接 传送门 思路 首先我们对\(a\)正反各跑一边\(LIS\),记录每个位置在前一半的\(LIS\)中应该放的位置\(ans1[i]\),后一半的位置\(ans2[i]\). 对于字典序最小的方案,我们找到第一个峰值,然后往前遍历.在\(i\)这个位置,如果它在\(LIS\)中放的位置是\(pos\),那么我们先看当前放在\(pos+1\)的值是否比它大,大的话就说明这个位置一定比前面放过在\(pos\)这个位置的更优(因为字典序更小,且\([1,i]\)一定可以放满\([1,pos-1

2019杭电多校第二场hdu6602 Longest Subarray(线段树)

Longest Subarray 题目传送门 解题思路 本题求一个最大的子区间,满足区间内的数字要么出现次数大于等于k次,要么没出现过.给定区间内的数字范围是1~c. 如果r为右边界,对于一种数字x,满足条件的左边界l的范围是r左边第一个x出现的位置+1(即这段区间内没有出现过x,如果x在1~r内都没有出现过,那么1~r自然都是l的合法范围),以及1到从右往左数数第k个x出现的位置(即这段区间内的x出现次数大于等于k).所以我们只要找到同时是c种数字的合法左边界的位置中最小的,然后枚举所有的i作

2019 杭电多校 第二场

2019 Multi-University Training Contest 2 补题链接:2019 Multi-University Training Contest 2 1005 Everything Is Generated In Equal Probability (HDU-6595) 题意 给出一个整数 \(N\),在 \([1,N]\) 中随机生成一个 \(n\).然后生成长度为 \(n\) 的全排列 \([1, n]\). 对该排列运行一个程序,程序先求当前排列的逆序对对数,然后随

2019杭电多校第九场

2019杭电多校第九场 熟悉的后半场挂机节奏,又苟进首页了,很快乐 1001. Rikka with Quicksort upsolved 不是我做的,1e9调和级数分段打表 1002. Rikka with Cake solved at 01:11 有一个矩形,给你很多射线(射线只有横平竖直的四个方向),问把矩形切成了多少块 队友说答案是交点数加一,作为一个合格的工具人,当然是把队友的想法实现啦 二维坐标离散化枚举纵坐标维护横坐标,常规套路,树状数组也可以做(我是线段树写习惯了根本没想起来还有

【2019.07.22】2019杭电多校第一场

补题地址:http://acm.hdu.edu.cn/listproblem.php?vol=56 题号:6578-6590 1001: 1002:线性基 https://blog.csdn.net/Cassie_zkq/article/details/96979461 1003: 1004: 1005:? 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 自闭场,但补题能学到好多算法和思维,继续加油鸭- 原文地址:https://www.cnblo

2019杭电多校第一场

所有题解都在注释里面. 1004: 1 /* 2 出题人的说法:最终通过停车线的时候,一定是一个车后面堵着剩余所有车.那么影响 3 时间的就只有最前面这辆车,所以对于每一辆车,假设是它与0车堵在一起的最靠前的一辆车. 4 那么可以计算出一个值.所有的车的计算值的最大值就是答案. 5 这个就是出题人的说法 ,时间复杂度是o(n) 6 7 我个人的理解:我们做这道题得注意到一个条件,就是对当前的车,先不要考虑后面的车. 8 只考虑它与前面的那一辆车的互相作用.考虑他们什么时候撞倒. 9 首先假设第一

Rikka with Game[技巧]----2019 杭电多校第九场:1005

Rikka with Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description Though both Rikka and Yuta are busy with study, on their common leisure, they

2019年杭电多校第九场07题(HDU6686+树形dp)

目录 题目链接 题意 思路 代码 题目链接 传送门 题意 定义\(L(a,b)\)为结点\(a\)到结点\(b\)的路径上的结点数,问有种\(pair(L(a,b),L(c,d))\)取值,其中结点\(a\)到结点\(b\)的路径与结点\(c\)到结点\(d\)的路径没有交叉. 思路 我们很容易想到要想两条路径不交叉,那么\(a,b\)与\(c,d\)必定在两棵不同的子树中,假设第一棵子树的直径位\(L1\),第二棵子树的直径为\(L2\),那么我们可以得知\([1,L1]\)必定可以与\([1

2015杭电多校(III)改题表

题号 hdu 类型 比赛 分配 最终 1001 5316 线段树 YES    √ 1002 5317 简单题 YES    √ 1003 5318 快速幂 YES    √ 1004 5319 模拟 YES    √ 1005 5320 数论   Z   1006 5321 数论   Z   1007 5322 dp YES    √ 1008 5323 搜索 YES    √ 1009 5324 树套树 NO W  √ 1010 5325 bfs YES    √ 1011 5326 简单题