HDU 1110 盒子嵌套 (数学思维)

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.

题意:刚看这道英语题的时候意思大概能读懂,大概就是问你一个长方形能不能放到另一个长方形里面,注意如果箱子是一样的a=4,b=4,x=4,y=4是放不进去的,必须要大于才行

思路:原来以为只要判断 a>x&&b>y就可以了,但是没有想到箱子可以斜着放,如果a>x&&b>y可以放,如果ab<=xy不可以放,如果b<y不可以,但是如果a<x的话就在判断斜着放的情况就行了,如果a>h就可以放进去,否则不能,求h的话要用到数学反余弦函数,还需要做辅助线判断角的度数,{注意:acos(m)=n的话,cos(n)=m},角的度数的话如图所示,应该很清楚了
在这里插入图片描述
代码如下:

#include <iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
    double  a,b,x,y;
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
        if(a<b){swap(a,b);}
        if(x<y){swap(x,y);}

        if(a>x&&b>y)
        {
            printf("Escape is possible.\n");continue;
        }
        if(b<y)
        {
             printf("Box cannot be dropped.\n");continue;
        }
        if(a*b<=x*y)
        {
            printf("Box cannot be dropped.\n");continue;
        }
        double angle,d,h;
         d=sqrt(x*x+y*y);
         angle=acos(y/d)-acos(b/d);
         h=cos(angle)*x+sin(angle)*y;
        if(a>h)
        {
            printf("Escape is possible.\n");
        }
        else
        {
            printf("Box cannot be dropped.\n");
        }

    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值