HDU 1110 Equipment Box (判断一个大矩形里面能不能放小矩形)
传送门:
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
10 10 8 8
8 8 10 10
Box cannot be dropped.
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 (判断一个大矩形里面能不能放小矩形)的更多相关文章
- java 坐标系运算 判断一个地理坐标是否在电子围栏 圆、矩形、多边形区域内
转载自:https://blog.csdn.net/Deepak192/article/details/79402694 测试没问题,我用的是原始坐标:要注意的是坐标转换问题,要看当前是属于什么坐标系 ...
- 判断一个面(Polygon)是不是矩形
判断一个面是不是矩形在GIS中很长用的功能,那么怎么判断一个面是不是矩形呢. 这里先要弄懂一些概念,面是什么,先看OGC标准的定义. 我的英文水平有限,(有翻译更好的请留言,如果翻译的准确将被采纳)大 ...
- 判断大文件是否上传成功(一个大文件上传到ftp,判断是否上传完成)
大文件上传ftp,不知道有没有上传完成,如果没有上传完成另一个程序去下载这个文件,导致下载不完整. 判断一个文件是否上传完成的方法: /** * 间隔一段时间去计算文件的长度来判断文件是否写入完成 * ...
- 图论期末大作业编程题(如何判断一个4连通4正则图为无爪、无K4图)
博士期间估计这可能是唯一一个要编程的作业,搞了半天弄出这个东西,放这里为以后用到的时候查找方便. 说来也是可笑,读博士期间发现大家对上课也都没什么兴趣,老师也是那么回事,都说博士期间学的课程是要有助于 ...
- HDU 1756 Cupid's Arrow 计算几何 判断一个点是否在多边形内
LINK:Cupid's Arrow 前置函数 atan2 返回一个向量的幅角.范围为[Pi,-Pi) 值得注意的是 返回的是 相对于x轴正半轴的辐角. 而判断一个点是否在一个多边形内 通常有三种方法 ...
- POJ 1380 Equipment Box (暴力枚举)
Equipment Box 题目链接: http://acm.hust.edu.cn/vjudge/contest/130510#problem/B Description There is a la ...
- Android 判断一个 View 是否可见 getLocalVisibleRect(rect) 与 getGlobalVisibleRect(rect)
Android 判断一个 View 是否可见 getLocalVisibleRect(rect) 与 getGlobalVisibleRect(rect) [TOC] 这两个方法的区别 View.ge ...
- C#算法之判断一个字符串是否是对称字符串
记得曾经一次面试时,面试官给我电脑,让我现场写个算法,判断一个字符串是不是对称字符串.我当时用了几分钟写了一个很简单的代码. 这里说的对称字符串是指字符串的左边和右边字符顺序相反,如"abb ...
- [译] AlphaGo 的确是一个大事件
[译] AlphaGo 的确是一个大事件 转自:http://www.jianshu.com/p/157a15de47df 字数3797 阅读696 评论0 喜欢4 作者:Michael Nielse ...
随机推荐
- Radix tree--reference
source address:http://en.wikipedia.org/wiki/Radix_tree In computer science, a radix tree (also patri ...
- (二) 修改IDEA自带的 maven 仓库
详细可见教程 :https://www.yiibai.com/testng/ 1.新建一个maven项目 Maven简介: Maven是一个项目管理和综合工具.Maven提供了开发人员构建一个完整的生 ...
- 深入理解JavaScript系列(17):面向对象编程之概论
介绍 在本篇文章,我们考虑在ECMAScript中的面向对象编程的各个方面(虽然以前在许多文章中已经讨论过这个话题).我们将更多地从理论方面看这些问题. 特别是,我们会考虑对象的创建算法,对象(包括基 ...
- geth
>geth --networkid 123 --dev --datadir "d:/blockchain/project/ethereum" --rpc --rpcaddr ...
- Android设备之间通过Wifi通信
之前写过PC与Android之间通过WIFI通信(通过Socket,可以在博客里面搜索),PC作为主机,Android作为客户机,现在手头有一台仪器通过wifi传输数据,如果仪器作为主机发射WIFI热 ...
- python函数名称空间与作用域、闭包
一.命名空间概念 1.命名空间(name space) 名称空间是存放名字的地方. 若变量x=1,1存放在内存中,命名空间是存放名字x.x与1绑定关系的地方. 2.名称空间加载顺序 python te ...
- SQLAlchemy的使用---数据库的创建与连接
# 1. 导入SQLAlchemy from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Col ...
- css居中那些事
一.css垂直居中 1.line-height(适用于单行文本居中) eg: html:<p class="wordp">123</p>- css: .w ...
- 首页的css
html,body{ margin:; padding:; background-color: lavenderblush; } a{ color:darkgray; } li{ list-style ...
- 移动Web布局
移动Web开发之移动页面布局 前言 本文针对手机设备设计的页面,并非兼容全设备的响应式布局,常见的MobileWeb页面如H5页面.手机页面.WAP页.webview页面等等.在不同尺寸的手机设备上, ...