传送门:

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. python中时间对象生成及时间格式的转换

    1.将字符串的时间转换为时间戳 方法: a = "2013-10-10 23:40:00" 将其转换为时间数组 import time timeArray = time.strpt ...

  2. java项目升级spring4.3.x 、jdk1.8 、tomcat8.5遇到的坑及解决方案

    在将spring3.x 升级为4.3.x,jdk1.7 tomcat7升级到jdk1.8.tomcat8.5过程中,碰到了很多问题,也学习到了很多东西,现将这些问题分享出来,方便大家后续遇到同样问题时 ...

  3. SVN服务器在Ubuntu16.04下搭建多版本库详细教程

    1  介绍  Subversion是一个自由,开源的版本控制系统,这个版本库就像一个普通的文件服务器,不同的是,它可以记录每一次文件和目录的修改情况.这样就可 以很方面恢复到以前的版本,并可以查看数据 ...

  4. 清除canvas画布内容--点擦除+线擦除

    清空canvas画布内容 1.重置宽或高 由于canvas每当高度或宽度被重设时,画布内容就会被清空,因此可以用以下方法清空:(此方法仅限需要清除全部内容的情况) var c=document.get ...

  5. SQL注入和XSS攻击的原理

    8.4 Web跨站脚本攻击 8.4.1  跨站脚本攻击的原理(1) 跨站脚本在英文中称为Cross-Site Scripting,缩写为CSS.但是,由于层叠样式表 (Cascading Style ...

  6. mysql 常用操作语句

    1 根据表中的其中一个字段的值来修改同行某字段的值 UPDATE  radar a INNER JOIN radar b ON a.id=b.id SET a.letter=LEFT(b.filena ...

  7. Arcgis flex 切片地图麻点

    在arcgis server中发布地图切片完成后,有时候在访问地图的时候会出现很多麻点, 其实是你切片的时候没有注意到一些选项.... 默认的切片是PNG8,说到这可能就明白了吧,png8的色彩范围: ...

  8. android launcher

    1.android_launcher的源码详细分析 2.android---launcher 3.Android 4.4 Launcher3桌面源码分析 4.通过深度剖析Android之Launche ...

  9. css 字体样式设置

    css字体样式(Font Style),属性 时间:2014-05-08 21:49 来源:我爱学习网 | 作者:我爱学习网 | 本文已影响 68353 人   css字体样式(Font Style) ...

  10. C#并行库(TaskParallelLibrary)用法 z

    1. Task.Factory.StartNew(() => DoSomeWork());是异步的 下面的代码会先输出ddd,因为Task.Factory.Startnew不阻塞: var ta ...