CIRCLE_E - Three Circle Problem (EASY)
no tags
Given 3 distinct circles with positive integer radius R1, R2, and R3, and arranged like in the picture below:

Now, your task is to compute radius of small circle that can be created like yellow circle in the picture above. All circles in the picture above tangent each other.
Input
The first line in the input data, there is an integer T(0 < T ≤ 103) denoting number of test cases, than T lines follow.
For each lines, there are three integer R1, R2, and R3, (0 < {R1,R2,R3} < 109) denoting radius of each circle like in the picture above.
Output
For each test case, output radius of small circle that can be made, like in the picture above. Any output with absolute error less than 10-6 is accepted.
Example
Input:
3
1 1 1
10 10 10
23 46 69
Output:
0.154701
1.547005
6.000000
Solution:
for details visit https://en.wikipedia.org/wiki/Descartes%27_theorem
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
double ra,rb,rc;
cin>>ra>>rb>>rc;
double ans=(1.0/ra+1.0/rb+1.0/rc)+2*sqrt(1.0/(ra*rb)+1.0/(rb*rc)+1.0/(rc*ra));
ans=1.0/ans;
printf("%.6lf\n",ans);
}
return 0;
}
0 comments :
Post a Comment