Description
给定三个点(不共线)的坐标,要求以这三个点为圆心做三个圆,圆两两不相交,不包含,问三个圆的直径和最大为多少。
Input
第一行为测试数据组数t。接下来t行每行6个数为坐标。
Output
T行,每行一个整数表示直径和(取下整)。
Sample Input
1
0 0 0 1 1 0
Sample Output
3
.
.
.
.
.
分析
可以自己画图证明。最大的三个圆形直径就是等于三个点围成的三角形的周长。
.
.
.
.
.
程序:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while (t--)
{
double x1,y1,x2,y2,x3,y3;
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
double ans=0;
ans+=((double)sqrt((double)(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
ans+=((double)sqrt((double)(x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)));
ans+=((double)sqrt((double)(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)));
ans=floor((double)ans);
printf("%0.0lf\n",ans);
}
return 0;
}