您的位置:首页 > 产品设计 > UI/UE

多校2 1002 Buildings

2015-07-23 18:38 477 查看

Buildings

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


[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 <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int n,m,x,y;
while(scanf("%d %d %d %d",&n,&m,&x,&y)!=EOF)
{
int s=0,k=0;
int flg=1,misetp;
misetp=min(x-1,y-1);
misetp=min(misetp,n-x);
misetp=min(misetp,m-y);
s=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;
s++;
n=n-2,m=m-2;
if(n<=0 || m<=0)
break;
x--,y--;
if(x==0 || x==n+1 || y==0 || y==m+1)
{
flg=0;
if((n>=2 && m>=3) || (n>=3 && m>=2))
{
if(1<x && x<n)
{
k=min(x,n-x+1);
k=min(k,m);
k=k+s;
}
else if(1<y && y<m)
{
k=min(y,m-y+1);
k=min(k,n);
k=k+s;
}
}
}
}
if(n>0 && m>0)
{
s=s+min(n/2+n%2,m/2+m%2);
}
if(k>s)
s=k;
printf("%d\n",s);
}
return 0;
}


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