最新消息:点击查看大S的省钱秘笈

POJ 1380 Equipment Box C语言版

POJ题解 Slyar 85浏览 0评论

文章作者:姜南(Slyar) 文章来源:Slyar Home (www.slyar.com) 转载请注明,谢谢合作。

计算几何

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个浮点数,分别表示两个矩形的长和宽,问后一个矩形能否放入前一个矩形内(小矩形不允许接触大矩形)。

刚看到这题第一反应就是矩形可以转,也就是可以斜放...因为如果不是这样的话,那这题就和1+1没区别了...囧

pku1380

在纸上花了一个示意图,假设A、X总是长边,B、Y总是短边,考虑边的四种情况:

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

可以看出,有三种情况是一定可以直接判断的。剩下的一种就是需要旋转小矩形来看能否将其放入大矩形中了。

我们可以枚举旋转角,而旋转的目的就是减小长边,增大短边,这样我们只要看是否存在一个旋转角使得小矩形实际占用的边长小于大矩形边长即可。

转载请注明:Slyar Home » POJ 1380 Equipment Box C语言版

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (2)

  1. @wOOL, 对角线交点...囧,的确够YD...
    Slyar8年前 (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: 貌似这个解法最后的不等式整理出来和我给你的那个对角线的是等价的, 你可以推一下, 不过它在之前又进行了一次分支判断
    wOOL8年前 (2009-06-12)回复