HDU-1110 Equipment Box

题目衔接:http://acm.hdu.edu.cn/showproblem.php?pid=1110

Equipment Box
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3287    Accepted Submission(s): 828


Problem Description
There is a large room in the Pyramid called Room-of-No-Return. Its floor is covered by rectangular tiles of equal size. The name of the room was chosen because of the very high number of traps and mechanisms in it. The ACM group has spent several years studying the secret plan of this room. It has made a clever plan to avoid all the traps. A specially trained mechanic was sent to deactivate the most feared trap called Shattered Bones. After deactivating the trap the mechanic had to escape from the room. It is very important to step on the center of the tiles only; he must not touch the edges. One wrong step and a large rock falls from the ceiling squashing the mechanic like a pancake. After deactivating the trap, he realized a horrible thing: the ACM plan did not take his equipment box into consideration. The box must be laid onto the ground because the mechanic must have both hands free to prevent contact with other traps. But when the box is laid on the ground, it could touch the line separating the tiles. And this is the main problem you are to solve. 
 

Input
The input consists of T test cases. The number of them (T) is given on the first line of the input. Each test case consists of a single line. The line contains exactly four integer numbers separated by spaces: A, B, X and Y. A and Bindicate the dimensions of the tiles, X and Y are the dimensions of the equipment box (1 <= A, B, X, Y <= 50000). 
 

Output
Your task is to determine whether it is possible to put the box on a single tile -- that is, if the whole box fits on a single tile without touching its border. If so, you are to print one line with the sentence "Escape is possible.". Otherwise print the sentence "Box cannot be dropped.". 
 

Sample Input

 

2 10 10 8 8 8 8 10 10

 

Sample Output

 

Escape is possible. Box cannot be dropped.

 

Source

Central Europe 1999

题目大意:给你两个盒子的长宽让你判断第二个盒子能否放入第一个盒子中

思路:判断:

1:第一个的长宽均大于第二个毫无疑问能放进去

2: 第二个的面积不小于第二个或者第二个的宽不小于第一个肯定放不进去

3:还有最难想到的一种:斜着放进去这里我就不画图了直接从网上找了一幅图原文衔接是https://blog.csdn.net/blesslzh0108/article/details/62909744

图为

:è¿éåå¾çæè¿°

然后计算h是否大于a即可

代码:

/*

*/
#include<map>
#include<set>
#include <vector>
#include<stack>
#include<queue>
#include<cmath>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll unsigned long long
#define inf 0x3f3f3f
#define esp 1e-8
#define bug {printf("mmp\n");}
#define mm(a,b) memset(a,b,sizeof(a))
#define T() int test,q=1;scanf("%d",&test); while(test--)
const int maxn=1e6+10;
const double pi=acos(-1.0);
const int N=201;
const int mod=1e9+7;

bool judge(double a,double b,double c,double d)
{
    double z=sqrt(pow(c,2)+pow(d,2));
    double an=acos(d/z)-acos(b/z);
    double x=c*cos(an)+d*sin(an);
    if(x<a)
        return true;
    return false;
}

int main()
{
    T()
    {
        double a,b,c,d;
        scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
        int flag=1;
        if(a<b)
            swap(a,b);
        if(c<d)
            swap(c,d);
        if(a>c&&b>d)///第一个的长短边均大于第二个的`
        {
            printf("Escape is possible.\n");
            continue;
        }
        if(c*d>=a*b||d>=b)///面积大于第一个或者最短边大于第一个肯定放不进去
        {
            printf("Box cannot be dropped.\n");
            continue;
        }
        if(judge(a,b,c,d))///斜着放
        {
            printf("Escape is possible.\n");
        }
        else
            printf("Box cannot be dropped.\n");
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/lee371042/article/details/89047496
Box