hdu1110:Equipment Box 之计算几何

时间:2023-02-10 20:16:37


Equipment Box

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1482    Accepted Submission(s): 351


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
 

Recommend
Eddy   |   We have carefully selected several similar problems for you:   1103  1119  1115  1100  1104 
 又是一道计算几何的题目。
该题说白了,就是判断一个长方形能否严格覆盖另一个长方形的题
AC代码如下:
#include<iostream>
#include<cstdio>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
#define pi 3.141592653


int main()
{
    int T;
    double x1, y1, a1, b1;
	double i;
    freopen("in.txt", "r", stdin);

    cin >> T;
    while (T--){
        cin >> x1 >> y1 >> a1 >> b1;
		bool flag=false;
		double c1,d1;
		double t;
		if(x1>a1&&y1>b1){
			cout<<"Escape is possible."<<endl;
			continue;
		}
		if(y1>a1&&x1>b1){
			cout<<"Escape is possible."<<endl;
			continue;
		}
		
		for(i=0;i<90;i+=0.2){
			double angle=(i*pi)/180.0;
			if(a1*sin(angle)+b1*cos(angle)<x1&&a1*cos(angle)+b1*sin(angle)<y1){
				cout<<"Escape is possible."<<endl;
				flag=true;
				break;
			}
		}
		
		if(!flag){
			cout<<"Box cannot be dropped."<<endl;
		}
    }
    return 0;
}