ZOJ 3806 Incircle and Circumcircle(几何+二分)
来源:互联网 发布:斗地主软件源码 编辑:程序博客网 时间:2024/04/30 01:27
题目大意:给你一个三角形的内接圆的半径和外接圆的半径,让你找出符合条件的三角形的三条边的边长。如果没有输出“NO Solution!”。
首先是判断是否可以构成三角形:
如图:
当 内切圆与外接圆的圆心相同时,为构成符合条件的三角形的最大条件。
这样就找到了关系r*2 == R,所以当r*2 > R时是不存在这样的三角形的。
在满足的条件下,我们通过构造等腰三角形来找到满足条件的三条边,如图:
这道题目的解法是:二分底边长度找到满足条件的长度。
通过二分底边我们可以得到BC的长度,然后在ΔABC中求出AC的长度,AB=R。然后可以得到FC的长度,在ΔFBC中可以求出FB的长度。得到t。
我们在ΔFDE中求出FE,然后得到FC,再在ΔFBC中求出FB的长度tt,比较两次求得的长度,如果tt > t说明有界大了,否则说明左界大了。
注意eps
A triangle is one the basic shapes in geometry. It's a polygon with three vertices and three sides which are line segments. A triangle with vertices A, B, C is denoted ΔABC. And its three sides,BC, CA, AB are often denoted a, b and c.
The incircle of a triangle is the largest circle contained in the triangle, it is tangent to the three sides. The center of the incircle is called the triangle's incenter and the radius of the incircle is called inradius, which is denoted r.
The circumcircle of a triangle is the circle which passes through all its three vertices. The center of the this circle is called circumcenter and its radius is called circumradius, which is denotedR.
It's very easy to calculate r and R after knowing a, b and c. Now you are given r and R, can you calculate a valid triple (a, b, c)?
Input
There are multiple cases. Each case has two positive integers r and R in one line. (r and R are less than 105)
Ouput
For each case, print three floating numbers a, b and c in one line if it's possible to get r and R. If there are no possible tuples, print "NO Solution!".
The judge program uses your a, b and c to calculate the inradius and circumradius. Only the relative error of your inradius and circumradius less than 10-8 will be accepted.
Sample Input
1 22 59 9
Sample Ouput
3.464101615137754587 3.464101615137754587 3.4641016151377545876 8 10NO Solution!
#include <algorithm>#include <iostream>#include <stdlib.h>#include <string.h>#include <iomanip>#include <stdio.h>#include <string>#include <queue>#include <cmath>#include <stack>#include <map>#include <set>#define eps 1e-10///#define M 1000100///#define LL __int64#define LL long long///#define INF 0x7ffffff#define INF 0x3f3f3f3f#define PI 3.1415926535898#define zero(x) ((fabs(x)<eps)?0:x)using namespace std;const int maxn = 1010;int main(){ double R, r; while(cin >>r>>R) { if(2*r > R) { cout<<"NO Solution!"<<endl; continue; } double left = 0; double right = sqrt(3)*R; while(right-left > eps) { double mid = (left+right)/2.0; double t = sqrt(pow(sqrt((pow(R, 2.0)-pow((mid/2.0), 2.0)))+R, 2.0) + pow((mid/2.0), 2.0)); double tt = pow((sqrt(pow(r, 2.0)+pow((t-mid/2.0), 2))+r), 2.0)+pow((mid/2.0), 2.0); if(tt-pow(t, 2.0) < eps) right = mid; else left = mid; } double a = sqrt(pow(sqrt(pow(R, 2.0)-pow(left/2.0, 2.0))+R, 2.0)+pow(left/2.0, 2.0)); printf("%.18lf %.18lf %.18f\n", a, a, left); } return 0;}
- ZOJ 3806 Incircle and Circumcircle(几何+二分)
- ZOJ 3806 Incircle and Circumcircle(几何+二分)
- Incircle and Circumcircle - ZOJ 3806 几何
- zoj 3806 Incircle and Circumcircle(二分)
- 【ZOJ】3806 Incircle and Circumcircle
- zoj 3806 Incircle and Circumcircle
- ZOJ 3806 Incircle and Circumcircle
- ZOJ 3806 Incircle and Circumcircle 【几何】【special judge】
- zoj 3806 Incircle and Circumcircle(计算几何:高大上的二分解方程)
- Incircle and Circumcircle(二分+几何)浙大月赛zoj3806(详解版)图
- ZOJ3806-Incircle and Circumcircle
- zoj-3806(几何+二分)
- uva 11524 - InCircle(几何)
- InCircle - UVa 11524 几何
- UVA 11524 - InCircle (计算几何)
- uva 11524 InCircle 内切圆(计算几何)
- ZOJ 3913 Bob wants to pour water (计算几何+二分)
- ZOJ 3913 Bob wants to pour water (计算几何+二分)
- 故乡、远方、十年……
- 佛祖保佑符
- 【Linux命令】--read命令的用法
- jdk配置环境变量
- 百炼 2774 切木头 还是没ac,总是re
- ZOJ 3806 Incircle and Circumcircle(几何+二分)
- 对嵌入式Linux中的根文件系统的理解和解析
- Server_Virtual PC 2007教程;
- static用法
- http://poj.org/problem?id=1135
- Makefile
- CHARTING图表控件介绍及下载地址
- 择一城终老,遇一人白首
- 【瞎搞】HDU 1422 重温世界杯