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 ...
随机推荐
- es6展开运算符
数组的展开合并 现在有两个数组[1, 2, 3, 4]和[5, 6, 7],想要将两个函数拼接成一个新的函数. //es5的写法 let arr1 = [1, 2, 3, 4]; let arr2 = ...
- 用dom1来实现,根据光标移动自动给表单加上背景色,光标移开自动去除背景色
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- PHP 对象基础知识
最近开始重新学习对象知识,其实也算是初步深入学习对象和设计模式,希望自己会坚持下去,保持更新 初识PHP对象 还记得,刚开始学习 PHP 的时候,学到到方法和对象时有一个很大的疑问,对象与方法相比较那 ...
- thinkphp 3.2.3 - Route.class.php 解析(路由匹配)
class Route { public static function check(){ $depr = C('URL_PATHINFO_DEPR'); // '/' $regx = preg_re ...
- Vue钩子函数生命周期实例详解
vue生命周期简介 Vue实例有一个完整的生命周期,也就是从开始创建.初始化数据.编译模板.挂载Dom.渲染→更新→渲染.卸载等一系列过程,我们称这是Vue的生命周期.通俗说就是Vue实例从创建到销毁 ...
- CQRS之旅——旅程3(订单和注册限界上下文)
旅程3:订单和注册限界上下文 CQRS之旅的第一站 "寓言家和鳄鱼是一样的,只是名字不同" --约翰·劳森 描述: 订单和注册上下文有一部分职责在会议预订的过程中,在此上下文中,一 ...
- IOS开发学习笔记037-九宫格代码实现
九宫格布局,用手机输入法时经常见到.先按3行3列写. 代码的实现主要是计算插入图片的位置. 每一张图片的位置和所在的行列密切相关.分析过程如下: 界面: 代码实现 1.把需要的图片资源添加进来 然后给 ...
- ios开发学习笔记002-运算符
运算符 C语言有34种运算符,常见的有加减乘除. 算术运算符 1.加 10+2 2.减 20-2 3.乘 12*2 4.除 10/2 5.取余 10%3 = 1; 10%-3 = 1; -10%3 = ...
- SEO搜索引擎优化基础
要如何提高自己网站的知名度,那必须了解一些SEO知识. 1.什么是搜索引擎 所谓的搜索引擎(Search Engines)是一些能够主动搜索信息(搜索网页上的单词和简短的特定的内容描述)并将其自动索 ...
- 虚拟机安装教程(linux、centOS)
前提: Windows7系统 64位 VMware-workstation-full-11.0.0-2305329.exe CentOS-6.6-x86_64-bin-DVD1.iso 安装步骤: 看 ...