ZOJ1608 Two Circles and a Rectangle
Time Limit: 2 Seconds Memory Limit: 65536 KB
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
做点水题,舒缓心情,享受人生
简单计算几何
大概没什么好解释的,放进去两个圆以后,根据它们的“横纵方向最大间隔距离”和“半径之和”来判断能否装下。
/*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int mxn=;
double a,b,r1,r2;
int main(){
while(scanf("%lf%lf%lf%lf",&a,&b,&r1,&r2)!=EOF){
if(a<b)swap(a,b);
if(r1<r2)swap(r1,r2);
if(b<=r1*){printf("No\n");continue;}
double x1=a-r1-r2;
double y1=b-r1-r2;
double r=r1+r2;
if(x1*x1+y1*y1-r*r>=0.01)
printf("Yes\n");
else printf("No\n");
}
return ;
}
ZOJ1608 Two Circles and a Rectangle的更多相关文章
- 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 ...
- 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 ...
- Java基础之在窗口中绘图——使用模型/视图体系结构在视图中绘图(Sketcher 1 drawing a 3D rectangle)
控制台程序. 在模型中表示数据视图的类用来显示草图并处理用户的交互操作,所以这种类把显示方法和草图控制器合并在一起.不专用于某个视图的通用GUI创建和操作在SketcherFrame类中处理. 模型对 ...
- Circles and Pi
Circles and Pi Introduction id: intro-1 For as long as human beings exist, we have looked to the sky ...
- [LeetCode] Perfect Rectangle 完美矩形
Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover o ...
- [LeetCode] Max Sum of Rectangle No Larger Than K 最大矩阵和不超过K
Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix s ...
- [LeetCode] Smallest Rectangle Enclosing Black Pixels 包含黑像素的最小矩阵
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black ...
随机推荐
- mysql索引详细描述与应用场景
索引的数据结构: (1)一般是B+tree:MySql使用最频繁的一个索引数据结构,数据结构以平衡树的形式来组织,因为是树型结构,所以更适合用来处理排序,范围查找等功能. (2)Hash:Hsah索引 ...
- 数据结构-二分查找(Binary Search)
#include <stdio.h> #include <string.h> #include <stdlib.h> #define LIST_INIT_SIZE ...
- Lake Counting(dfs)
Description Due to recent rains, water has pooled in various places in Farmer John's field, which is ...
- 如何用eclipse运行导入的maven项目
1.配置jdk系统环境变量.找到安装的jdk的安装目录,新建系统环境变量,变量名为JAVA_HOME(作为一个引用),变量值为该路径. 找到Path,将%JAVA_HOME%/bin; 添加到变量值的 ...
- 水题:HDU-1088-Write a simple HTML Browser(模拟题)
解题心得: 1.仔细读题,细心细心...... 2.题的几个要求:超过八十个字符换一行,<br>换行,<hr>打印一个分割线,最后打印一个新的空行.主要是输出要求比较多. 3. ...
- 海量数据处理算法—BitMap
1. Bit Map算法简介 来自于<编程珠玑>.所谓的Bit-map就是用一个bit位来标记某个元素对应的Value, 而Key即是该元素.由于采用了Bit为单位来存储数据,因此在存储空 ...
- TCP/IP网络编程之优于select的epoll(一)
epoll的理解及应用 select复用方法由来已久,因此,利用该技术后,无论如何优化程序性能也无法同时接入上百个客户端.这种select方式并不适合以web服务端开发为主流的现代开发环境,所以要学习 ...
- service-worker实践
service-worker虽然已列入标准,但是支持的浏览器还是有限制,还有比较多的问题. 1. 生命周期 注册成功-------installing--------------> 安装成功(i ...
- 36、imageview的坑
当频繁设置imageview的背景图片时,用: imageviewChooseStaff.setImageResource(R.drawable.default_head_pic); 而不是 imag ...
- python-day4-装饰器的使用
摘要:某公司的基础开发平台,有大概N多个函数,boss要求小A,为每个函数添加权限验证功能,而且要求不得修改函数内部结构,让小A尝试从代码外部入手,作为新手小A来讲,这无疑是一个巨大的工作量,难道TM ...