# POJ 1380 Equipment Box C语言版

POJ题解 2827浏览

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 file. 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.

Slyar:说下题目大意。一共T组数据，每组数据给出4个浮点数，分别表示两个矩形的长和宽，问后一个矩形能否放入前一个矩形内(小矩形不允许接触大矩形)。

 A>X B>Y 可能 A>X B<=Y 不可能 A<=X B>Y 待定 A<=X B<=Y 不可能

```#include
#include
#include

#define PI acos(-1)

void swap(double* x, double* y)
{
double tmp;
tmp = *x;
*x = *y;
*y = tmp;
}

int main()
{
int t, sign;
double a, b, x, y;
scanf("%d", &t);
while(t--)
{
scanf("%lf%lf%lf%lf", &a, &b, &x, &y);
/* 使得a和x总是长边，b和y总是短边 */
if (a < b) swap(&a, &b);
if (x < y) swap(&x, &y);
/* a>x && b<=y 以及 a<=x && b<=y 均不可能 */
if (b <= y)
{
printf("Box cannot be dropped.\n");
continue;
}
/* a>x && b>y 可能 */
if (a > x && b > y)
{
printf("Escape is possible.\n");
continue;
}
/* 标记未找到 */
sign = 0;
/* 枚举 a<=x && b>y 的情况 */
for (i = 0; i <= 90; i += 0.2)
{
/* 将角度转换为弧度 */
rad = PI * i / 180;
{
printf("Escape is possible.\n");
/* 标记找到 */
sign = 1;
break;
}
}
if (!sign) printf("Box cannot be dropped.\n");
}
//system("pause");
return 0;
}
```

### 网友最新评论 (2)

1. @wOOL, 对角线交点...囧，的确够YD...
Slyar12年前 (2009-06-12)回复
2. 大S看看这个解法 https://www.ntnu.edu.tw/acm/ProblemSetArchive/B_EU_CERC/1999/box.c 比你的淫荡~ 但是78行有错误 应该是 L = (B + sqrt(Y * Y - (double)A * (double)A)) / 2; PS: 貌似这个解法最后的不等式整理出来和我给你的那个对角线的是等价的, 你可以推一下, 不过它在之前又进行了一次分支判断
wOOL12年前 (2009-06-12)回复