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 denoted R.
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!
题意:
题意很简单,就知道一个三角形的内切圆与外接圆的半径,让你求出三角形的三条边。
分析:
这是浙大月赛的题,在比赛的过程中没做出来。颇感遗憾。首先知道三角形的两个半径,那么,我们可以猜测这个三角形可能为特殊三角形,比如正三角形、直角三角形、等腰三角形等等。经过分析本题的答案不唯一,那么两个圆都会存在一个等腰三角形,这个也可以证明。那么我们求得三角形就为一个等腰三角形。之前我得出了当这个三角形为正三角形的时候就是边界条件,这时的内切圆会最大。然后二分三角形的底,得出答案。
代码:参考:http://blog.csdn.net/u014733623/article/details/38800873
#include<algorithm>
#include<iostream>
#include<fstream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#ifdef __int64
typedef __int64 LL;
#else
typedef long long LL;
#endif
#define inf 0x7ffffffff
#define eps 1e-10
#define N 1000005
int main() {
double R,r;
while(~scanf("%lf %lf",&r,&R)) {
if(r*2>R) {
cout<<"NO Solution!"<<endl;
continue;
}
double l=0,rr=R*sqrt(3)/2;
double mid;
double O,o,h,bian;
while(rr-l>eps) {
mid=(rr+l)/2;
O=sqrt(R*R-mid*mid);
h=O+R;
bian=sqrt(h*h+mid*mid);
o=(2*mid*h)/(2*bian+mid*2);
if(o<r)
l=mid;
else
rr=mid;
}
mid=(rr+l)/2;
O=sqrt(R*R-mid*mid);
h=O+R;
bian=sqrt(h*h+mid*mid);
printf("%.18f %.18f %.18f\n",mid*2,bian,bian);
}
return 0;
}