XDOJ1204 - the cover circle
来源:互联网 发布:网络空间通常从 描绘 编辑:程序博客网 时间:2024/06/05 15:52
Description
用半径相等的两个圆覆盖一个w*h的矩形,要求两圆不相交且必须在矩形内。求覆盖面积最大时两圆半径。
Input
输入包含多组数据,EOF结束。
每组数据包含一行,分别是两个实数w和h代表矩形的长和宽。
0<w,h<100000
每组数据包含一行,分别是两个实数w和h代表矩形的长和宽。
0<w,h<100000
Output
每组数据输出一行表示圆的半径,小数点后保留三位。
Sample Input
2 1
Sample Output
0.500
解题思路:
一道几何体,规定w>=h
1、如果w>=2h,则直接在两边放两个最大的球,r=h/2
2、如果h<=w<2h,建立坐标系,一个圆圆心为(r,r),另一个圆心为(w-r,h-r),由于两圆相切,则两心距离为2r,解方程得,r=(h+w-sqrt(2hw))/2,(这个公式是怎么来的?)
1、如果w>=2h,则直接在两边放两个最大的球,r=h/2
2、如果h<=w<2h,建立坐标系,一个圆圆心为(r,r),另一个圆心为(w-r,h-r),由于两圆相切,则两心距离为2r,解方程得,r=(h+w-sqrt(2hw))/2,(这个公式是怎么来的?)
#include <iostream>#include <iomanip>#include <cmath>using namespace std;double w,h;int main(){ while (cin>>w>>h) { double t; if (w<h) { t=w; w=h; h=t; } if (w>=h+h) t=h/2; else t=(w+h-sqrt(2*h*w))/2; cout<<fixed<<setprecision(3)<<t<<endl; }}
0 0
- XDOJ1204 - the cover circle
- ACdream1034:the cover circle
- acd the cover circle(分情况讨论)
- Cover the inline style
- The testing skill--collection cover.
- HDU-4145 Cover The Enemy
- hdu 4145 Cover The Enemy
- HDU 4145: Cover The Enemy
- POJ 1382 Cover The Island
- The Circumference of the Circle
- pku2242The Circumference of the Circle
- Cover
- cover
- cover
- cover
- cover
- cover
- cover
- 随便
- Android SDK Manager国内下载缓慢的问题
- Ubuntu13.10(64bit)安装32位程序
- STL之stack,queue,优先队列
- 虚拟键盘常用处理
- XDOJ1204 - the cover circle
- javax.servlet.jsp.tagext.TagAttributeInfo和报错
- Redhat 停止sendmail的方法
- Android内存管理
- CF 463C Gargari and Bishops (贪心)
- Mac版的Android Eclipse识别手机问题
- Android常用属性
- C++设计模式之状态模式(三)
- C++11新特性学习笔记