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): 2989    Accepted Submission(s): 759


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
分析:
题目意思:
问你一个大矩形里面能不能放一个小矩形
 思路:
1.大矩形长边大于小矩形长边并且大矩形短边大于小矩形短边 肯定可以放进
 
2.小矩形面积大于大矩形或者小矩形最短边大于大矩形最短边 肯定放不下
 
3.画图。。。(图片拖起来看,文本格式问题。。。。。。。。。)

code:

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define max_v 25
bool f(double A,double B,double a,double b)
{
    double d=sqrt(a*a+b*b);
    double a1=asin(A/d);
    double a2=asin(b/d)*2.0;
    double h=cos(a1-a2)*d;
    if(B>h)
        return true;
    else
        return false;
}
int main()
{
    int t;
    bool flag;
    scanf("%d",&t);
    while(t--)
    {
        double A,B,a,b;
        scanf("%lf %lf %lf %lf",&A,&B,&a,&b);
        if(A<B)
            swap(A,B);
        if(a<b)
            swap(a,b);
        if(A>a&&B>b)//大矩形长边大于小矩形长边并且大矩形短边大于小矩形短边 肯定可以放进
        {
            flag=true;
        }
        else if(A*B<=a*b||b>=B)//小矩形面积大于大矩形或者小矩形最短边大于大矩形最短边 肯定放不下
        {
            flag=false;
        }else
        {
            flag=f(A,B,a,b);
        }
        if(flag)
        {
            cout << "Escape is possible." << endl;

        }else
        {
            cout << "Box cannot be dropped." << endl;

        }
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/yinbiao/p/9326818.html

相关文章