ZOJ 3806 Incircle and Circumcircle
题意:已知三角形的内接圆半径和外接圆半径,求符合的三角形边长
思路:假设是等腰三角形,内接圆半径最大的情况是等边三角形,直接在(0,pi/3)范围内二分底角
#include <iostream> #include <cmath> #include <stdio.h> #include <algorithm> using namespace std; #define eps 1e-10 double pi=2*asin(1.0); int main() { double r,R; int i,j,k; while(scanf("%lf%lf",&r,&R)!=EOF) { if(2*r>R) {printf("NO Solution!\n");continue;} double left=0,right=pi/3.0; double A,B,C; while(left+eps<right) { double mid=(left+right)/2; A=B=mid; C=pi-mid-mid; double tp=4*R*sin(A/2)*sin(B/2)*sin(C/2); if(tp<r) left=mid; else right=mid; } printf("%.10f %.10f %.10f\n",2*R*cos(C/2),2*R*cos(C/2),2*2*R*cos(C/2)*cos(A)); } return 0; }