ZOJ 1608 Two Circles and a Rectangle
Give you two circles and a rectangle, your task is to judge wheather the two circles can be put into the rectangle with no part of circles outside the retangle.
Input
There are multiple test cases. In every test cast, there are four float-point numbers:
a, b, r1, r2
where, a and b are two sides of the rectangle, r1 and r2 are radii of the two circls.
Output
Print a "Yes", if the circles can be put into the rectangle. Otherwise, print a "No".
You can safely assume x < y, where x and y are float-point numbers, if x < y + 0.01.
Sample Input
5 4 1 1
5 4 1.5 2
Sample Output
Yes
No
//数学一本通习题 1
//ZOJ 1608 判断两个圆能否放入一个矩形中 //题意:给你一个矩形和两个圆,问能否把这两个圆放进矩形里(圆不能相交或包含) //最好(省空间)的放置方法显然是两个圆分别与两条对边相切,且这两个圆也相切
//假如两个圆是按上面的方法放的,且刚好能放下(即两组邻边分别与两个圆相切)
//那么假设两个圆圆心的距离是z
//以z为斜边,x平行于长,y平行于宽做直角三角形 ,则
//z=r1+r2
//x=a-r1-r2=a-z
//y=b-r1-r2=b-z
//所以,z是固定的,x和y取决于矩形的边长
//那么如果x^2+y^2==z^2的话,就是刚好能放下,>=就是能放下了 #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std; const int N=1e5+; double a,b,r1,r2;
double x,y,z; int main()
{
while(scanf("%lf%lf%lf%lf",&a,&b,&r1,&r2)!=EOF)
{
z=r1+r2;
if(a<b) //让a是长边,b是短边
swap(a,b);
if(r1<r2) //r1是大圆,r2是小圆
swap(r1,r2);
x=a-z,y=b-z;
if(x*x+y*y>=z*z)
puts("Yes");
else
puts("No");
}
return ;
}
ZOJ 1608 Two Circles and a Rectangle的更多相关文章
- ZOJ1608 Two Circles and a Rectangle
Time Limit: 2 Seconds Memory Limit: 65536 KB Give you two circles and a rectangle, your task is ...
- LightOJ 1366 - Pair of Touching Circles (统计矩形内外切圆对)
1366 - Pair of Touching Circles PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limi ...
- javascript: jquery.gomap-1.3.3.js
from:http://www.pittss.lv/jquery/gomap/solutions.php jquery.gomap-1.3.3.js: /** * jQuery goMap * * @ ...
- how to detect circles and rectangle?
opencv中对圆检测的函数为:HoughCircles(src_gray,circles,CV_HOUGHT_GRADIENT,1,src_gray.cols/8,200,100,0,0) circ ...
- ZOJ 1985 Largest Rectangle in a Histogram(刷广告)2010辽宁省赛
Largest Rectangle in a Histogram Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21204 ...
- ZOJ 2589 Circles(平面图欧拉公式)
[题目链接] http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2589 [题目大意] 给出一些圆,问这些圆可以把平面分为几个部 ...
- Java基础之在窗口中绘图——使用模型/视图体系结构在视图中绘图(Sketcher 1 drawing a 3D rectangle)
控制台程序. 在模型中表示数据视图的类用来显示草图并处理用户的交互操作,所以这种类把显示方法和草图控制器合并在一起.不专用于某个视图的通用GUI创建和操作在SketcherFrame类中处理. 模型对 ...
- ZOJ题目分类
ZOJ题目分类初学者题: 1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 13 ...
- zoj 1010 Area【线段相交问题】
链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1010 http://acm.hust.edu.cn/vjudge/ ...
随机推荐
- Appium_Page object设计模式
Page object设计模式思维,把app按页面去划分,一个页面就是一个page对象 每个页面的元素集中管理.页面上按钮操作方法单独封装 # __author__ = " Caric Le ...
- java 单链表反转
最近与人瞎聊,聊到各大厂的面试题,其中有一个就是用java实现单链表反转.闲来无事,决定就这个问题进行一番尝试. 1.准备链表 准备一个由DataNode组成的单向链表,DataNode如下: pub ...
- mysql数据库备份之主从同步配置
主从同步意义? 主从同步使得数据可以从一个数据库服务器复制到其他服务器上,在复制数据时,一个服务器充当主服务器(master),其余的服务器充当从服务器(slave).因为复制是异步进行的,所以从服务 ...
- JDBC第一个案例
1.概述 JDBC(Java DataBase Connectivity) 是 Java 提供的用于执行 SQL 语句一套 API,可以为多种关系型数据库提供统一访问,由一套用 Java 语言编写的类 ...
- 【洛谷 P4052】 [JSOI2007]文本生成器(AC自动机,DP)
题目链接 AC自动机上dp第一题嗷. 如果直接求可读文本的数量,显然要容斥,不好搞. 于是考虑求不可读文本的数量,再用\(26^m\)减去其即可. 建出AC自动机,如果一个节点为单词结尾或其fail链 ...
- DateTimePicker控件CustomFormat格式字符串及其说明
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/wuzhanwen/article/details/78800720格式字符串 描述 d 一个或两位数 ...
- webapp之登录页面当input获得焦点时,顶部版权文本被顶上去 的解决方法
如上图,顶部版权是用绝对定位写的,被顶上去了,解决方法是判断屏幕大小,改变footer的定位方式: <script> var oHeight = $(document).height(); ...
- python的continue和break
continue:表示终止当前循环,开始下一次循环 break:终止所有循环 s = 0 while s < 3: s += 1 print(s) continue#'@' print(abc) ...
- android studio创建模拟器
开发环境: 操作系统: windows10 教育版 1903 Android studio : Android Studio 3.5.1Build #AI-191.8026.42.35.590020 ...
- springboot 使用常用注解
找到方法封装成json格式 @RestController = @Controller+@ResponseBody //一个组合注解,用于快捷配置启动类,springboot启动主入口 @Spring ...