[CodeFights] Changu Circle
Changu ,after his death reached hell and was given 3 numbers ( a , b , c ) of the form n^2+1 or m^2-1 or 2k ( s.t all 3 integers are of different forms for some integer n,m,k). He tries to make a triangle T using these 3 numbers as side lengths. Now he wants to calculate the minimum INTEGER radius r of a circle such that r is greater than or equal to the radius of circumcircle of the triangle T. Can you help him find this radius.
Note: Output should be -1 if no triangle can be formed using these lengths (a,b,c). Output -1 in case a triangle of zero area is being formed.
Constraints: -10^6<=a,b,c<=10^6
Input (a) → integer :
Input (b) → integer :
Input (c) → integer :
Output → integer :
The required radius r
这次是最短代码竞赛= =
然而我却只有第二TAT
1 int changu_circle(int a, int b, int c) { 2 return a+b+c<=2*(a=(a=a>b?a:b)>c?a:c)?-1:a/2+a%2; 3 }
这篇文章由TonyFang发布。
所有解释权归TonyFang所有。
Mailto: tony-fang@map-le.net