ZOJ 3806 Incircle and Circumcircle(幾何+二分)
題目大意:給你一個三角形的內接圓的半徑和外接圓的半徑,讓你找出符合條件的三角形的三條邊的邊長。如果沒有輸出“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 2 2 5 9 9
Sample Ouput
3.464101615137754587 3.464101615137754587 3.464101615137754587 6 8 10 NO 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;
}
相關文章
- CodeForces 887 E. Little Brother(計算幾何+二分)
- 平面幾何
- 計算幾何
- zoj5093Battle ships【二分圖 棋盤覆蓋有斷點】BAT斷點
- 計算幾何 —— 二維幾何基礎 —— 距離度量方法
- 計算幾何:模板
- CF18A 幾何
- 美國人的幾何
- 計算幾何模板
- 幾何本質初步猜想
- HDU 6055 Regular polygon(幾何)Go
- [筆記] 計算幾何筆記
- 寵物醫療,成色幾何?
- 二維幾何基礎
- 異構幾何問題
- 幾道經典的幾何作圖趣題
- three.js 幾何體(二)JS
- three.js 幾何體(三)JS
- 幾何庫從零開始
- 【計算幾何】向量表示
- geogebra幾何畫圖工具用法
- 【總結】計算幾何模板
- 二維幾何常用運算
- 二維計算幾何模板
- IV.4 代數幾何
- Points on Cycle (hdu1700,幾何)
- 【計算幾何】線段相交
- Kite(幾何+鏡面對稱)
- 三維計算幾何模板
- 貴國上網速度幾何?
- IT認證價值幾何 (轉)
- Something about 計算幾何
- ZOJ First Digit(瞎搞)Git
- Diablo III ZOJ - 3769
- 論 DevOps 實踐有幾何?dev
- 數學趣題:平面幾何(一)
- 數學趣題:平面幾何(二)
- 俄羅斯總理的幾何題