您的位置:首页 > 大数据 > 人工智能

2015 Multi-University Training Contest 2 1002

2015-07-26 00:00 525 查看

Buildings

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


[align=left]Problem Description[/align]

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.

#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<stdlib.h>
#include<algorithm>
#define LL __int64
using namespace std;
int n,m,x,y;
int main()
{
while(scanf("%d %d %d %d",&n,&m,&x,&y) != EOF)
{
if(n>m)
{
swap(n,m);
swap(x,y);
}
int ans=(n+1)/2;
if(n%2==1 && x==y && n==m && x==n/2+1)
ans=ans-1;
int len=max(x-1,n-x);
int ans1=min(m-y+1,min(len,y));
ans=max(ans1,ans);
printf("%d\n",ans);
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: