传送门:

http://acm.hdu.edu.cn/showproblem.php?pid=1110

Equipment Box

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

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
分析:
题目意思:
问你一个大矩形里面能不能放一个小矩形
 思路:
1.大矩形长边大于小矩形长边并且大矩形短边大于小矩形短边 肯定可以放进
 
2.小矩形面积大于大矩形或者小矩形最短边大于大矩形最短边 肯定放不下
 
3.画图。。。(图片拖起来看,文本格式问题。。。。。。。。。)

code:

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define max_v 25
bool f(double A,double B,double a,double b)
{
double d=sqrt(a*a+b*b);
double a1=asin(A/d);
double a2=asin(b/d)*2.0;
double h=cos(a1-a2)*d;
if(B>h)
return true;
else
return false;
}
int main()
{
int t;
bool flag;
scanf("%d",&t);
while(t--)
{
double A,B,a,b;
scanf("%lf %lf %lf %lf",&A,&B,&a,&b);
if(A<B)
swap(A,B);
if(a<b)
swap(a,b);
if(A>a&&B>b)//大矩形长边大于小矩形长边并且大矩形短边大于小矩形短边 肯定可以放进
{
flag=true;
}
else if(A*B<=a*b||b>=B)//小矩形面积大于大矩形或者小矩形最短边大于大矩形最短边 肯定放不下
{
flag=false;
}else
{
flag=f(A,B,a,b);
}
if(flag)
{
cout << "Escape is possible." << endl; }else
{
cout << "Box cannot be dropped." << endl; }
}
return ;
}

HDU 1110 Equipment Box (判断一个大矩形里面能不能放小矩形)的更多相关文章

  1. java 坐标系运算 判断一个地理坐标是否在电子围栏 圆、矩形、多边形区域内

    转载自:https://blog.csdn.net/Deepak192/article/details/79402694 测试没问题,我用的是原始坐标:要注意的是坐标转换问题,要看当前是属于什么坐标系 ...

  2. 判断一个面(Polygon)是不是矩形

    判断一个面是不是矩形在GIS中很长用的功能,那么怎么判断一个面是不是矩形呢. 这里先要弄懂一些概念,面是什么,先看OGC标准的定义. 我的英文水平有限,(有翻译更好的请留言,如果翻译的准确将被采纳)大 ...

  3. 判断大文件是否上传成功(一个大文件上传到ftp,判断是否上传完成)

    大文件上传ftp,不知道有没有上传完成,如果没有上传完成另一个程序去下载这个文件,导致下载不完整. 判断一个文件是否上传完成的方法: /** * 间隔一段时间去计算文件的长度来判断文件是否写入完成 * ...

  4. 图论期末大作业编程题(如何判断一个4连通4正则图为无爪、无K4图)

    博士期间估计这可能是唯一一个要编程的作业,搞了半天弄出这个东西,放这里为以后用到的时候查找方便. 说来也是可笑,读博士期间发现大家对上课也都没什么兴趣,老师也是那么回事,都说博士期间学的课程是要有助于 ...

  5. HDU 1756 Cupid's Arrow 计算几何 判断一个点是否在多边形内

    LINK:Cupid's Arrow 前置函数 atan2 返回一个向量的幅角.范围为[Pi,-Pi) 值得注意的是 返回的是 相对于x轴正半轴的辐角. 而判断一个点是否在一个多边形内 通常有三种方法 ...

  6. POJ 1380 Equipment Box (暴力枚举)

    Equipment Box 题目链接: http://acm.hust.edu.cn/vjudge/contest/130510#problem/B Description There is a la ...

  7. Android 判断一个 View 是否可见 getLocalVisibleRect(rect) 与 getGlobalVisibleRect(rect)

    Android 判断一个 View 是否可见 getLocalVisibleRect(rect) 与 getGlobalVisibleRect(rect) [TOC] 这两个方法的区别 View.ge ...

  8. C#算法之判断一个字符串是否是对称字符串

    记得曾经一次面试时,面试官给我电脑,让我现场写个算法,判断一个字符串是不是对称字符串.我当时用了几分钟写了一个很简单的代码. 这里说的对称字符串是指字符串的左边和右边字符顺序相反,如"abb ...

  9. [译] AlphaGo 的确是一个大事件

    [译] AlphaGo 的确是一个大事件 转自:http://www.jianshu.com/p/157a15de47df 字数3797 阅读696 评论0 喜欢4 作者:Michael Nielse ...

随机推荐

  1. 字典表+委托替代switch解决思路

    参考:http://www.jianshu.com/p/8887b3b3e8ba 代码 namespace 解决Switch { class Program { delegate string fun ...

  2. 在SourceTree中使用Git submodule

    在開發的過程中我們的項目可能會引用其他的版本庫中的代碼, 例如公司已經累積了一套公用的函式庫, 被多個項目調用;  很顯然地, 不能把公用函式庫的文件直接放到我們開發中的項目中, 這樣不但項目的冗餘, ...

  3. 如何运营亿级QPS的Redis系统

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 作者:冯伟源,高级工程师,腾讯云Redis系统运维负责人.6年DBA经验,一直从事SQL优化.实例调优.数据库架构.海量数据库集群运维.运营 ...

  4. js根据子目录数目显示父级目录

    需求:<ul>中<li>数量为0,则不显示<ul>以及<b>:<div>中<ul>数量为0,则不显示<div> 1. ...

  5. C# 安装WindowService服务和相关

    https://www.cnblogs.com/charlie-chen2016/p/8031774.html 这是一个备份数据库的服务,逻辑很简单,就是通过定时器实现在特定的时间执行SQL语句备份数 ...

  6. WebGrease—异常来自 HRESULT:0x80131040

    一.错误源: 未能加载文件或程序集“WebGrease, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一 ...

  7. 新手的grid布局

    html部分 <!DOCTYPE html><html><head><meta charset="utf-8"><link r ...

  8. webstorm上传vue代码至git

    Git在push时候,提示:push to origin/master was rejected 解决方案如下: 提交代码顺序 webstorm右键项目名称==>Git==>Commit ...

  9. js数组插入指定位置元素,删除指定位置元素,查找指定位置元素算法

    将元素x插入到顺序表L(数组)的第i个数据元素之前 function InsertSeqlist(L, x, i) { // 将元素x插入到顺序表L的第i个数据元素之前 if(L.length == ...

  10. Ubuntu 查找文件夹中内容包含关键字的文件,路径为当前文件夹

    From CSDN http://blog.csdn.net/lizhenmingdirk/article/details/44834997 grep -rl "keyword" ...