Triangle
Time Limit: 1000msMemory Limit: 65536KB 64-bit integer IO format: %lld Java class name: Main
Prev Submit Status Statistics Discuss Next
Type:
None
Tag it!
在三角形ABC内部选取一点P,过P作到三条边的垂线,D,E,F是P到BC,CA,AB的垂足。
设S=BC/PD+CA/PE+AB/PF
问P点位于什么地方的时候S的值最小。
Input
输入数据包含三行,每行包含两个实数,分别给出三角形三个顶点A,B,C的坐标。
Output
输出两个实数,给出S值最小时候的P点坐标,保留两位小数。
Sample Input
0.0 1.0
1000.0 0.0
-1000.0 0.0
Sample Output
0.00 0.50
//很明显的求内切圆的圆心
Source
第八届北京师范大学程序设计竞赛网络预赛
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
double x1,y1,x2,y2,x3,y3;
double a,b,c;
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
a=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
c=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
printf("%.2lf %.2lf\n",(a*x1+b*x2+c*x3)/(a+b+c),(a*y1+b*y2+c*y3)/(a+b+c));
return 0;
}