题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1700
题意:
一个圆心为原点的圆,告诉你圆上一点,求圆上另外两点的坐标使圆的面积最大
分析:
=√(2Rx-x^2)+(1/2)*(2Rx-x^2)^(-1/2)*(2R-2x)*x=(2Rx-x^2+Rx-x^2)/√(2Rx-x^2)=0,#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--){
double x1,y1,r;
scanf("%lf%lf",&x1,&y1);
r = x1*x1+y1*y1;
double a = 1;
double b = y1;
double c = r/4-x1*x1;
double delta = b*b-4*a*c;
double ansy1 = (-b-sqrt(delta))/2/a;
double ansy2 = (-b+sqrt(delta))/2/a;
double ansx1,ansx2;
if(fabs(x1)<=1e-7){
ansx1 = -sqrt(r-ansy1*ansy1);
ansx2 = sqrt(r-ansy2*ansy2);
}
else{
ansx1 = (-r/2-y1*ansy1)/x1;
ansx2 = (-r/2-y1*ansy2)/x1;
}
printf("%.3lf %.3lf %.3lf %.3lf\n",ansx1,ansy1,ansx2,ansy2);
}
return 0;
}
HDU1700 Points on Cycle (最大内接三角形)
原文:http://blog.csdn.net/bigbigship/article/details/41701331