Equipment Box
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>b x>y
1. a>x&&b>y 肯定能装下
2. a*b<=x*y or b<y 肯定装不下
3. h<b 能装下,h>=b 装不下 (具体过程我就不证明了,可以看别的大佬写的)
代码:
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll long long
#define inf 0x3f3f3f
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
double a,b,x,y;
scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
if(a<b) swap(a,b);
if(x<y) swap(x,y);
int flag=0;
if(a>x&&b>y) flag=1;
else if(a*b<=x*y||b<y) flag=0;
else
{
double d=sqrt(x*x+y*y);
double q=2*asin(y/d);
double p=asin(a/d);
double h=d*cos(p-q);
if(b>h) flag=1;
else flag=0;
}
if(flag) printf("Escape is possible.\n");
else printf("Box cannot be dropped.\n");
}
return 0;
}