游客 Signup | Login
中文 | En

1085 - 计算圆的周长

如果告诉你圆的直径,那么计算圆的周长是非常简单的。但是,这次不告诉你圆的直径。
现给你圆周上三个点的坐标,请你计算圆的周长。

Input

输入包含多组测试数据。每组输入包含6个实数x1,y1,x2,y2,x3,y3,表示圆周上三个点的坐标。
圆的直径不会超过1000000。

Output

对于每组输入,输出圆的周长,结果保留2位小数。(pi的取值为3.141592653589793)

Examples

Input

0.0 -0.5 0.5 0.0 0.0 0.5
0.0 0.0 0.0 1.0 1.0 1.0
5.0 5.0 5.0 7.0 4.0 6.0
0.0 0.0 -1.0 7.0 7.0 7.0
50.0 50.0 50.0 70.0 40.0 60.0
0.0 0.0 10.0 0.0 20.0 1.0
0.0 -500000.0 500000.0 0.0 0.0 500000.0

Output

3.14
4.44
6.28
31.42
62.83
632.24
3141592.65

Solution C

#include<stdio.h>
#include<math.h>

#define pi 3.141592653589793

double sqr(double x)
{
	return x*x;
}

int main()
{
	double x1,y1,x2,y2,x3,y3,a,b,c,r;
	while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF)
	{
		a=sqr(x1-x2)+sqr(y1-y2);
		b=sqr(x1-x3)+sqr(y1-y3);
		c=sqr(x2-x3)+sqr(y2-y3);
		r=sqrt(c/4/(1-sqr(a+b-c)/4/a/b));
		printf("%.2lf\n",2*pi*r);
	}
	return 0;
}

Solution C++

#include<stdio.h>
#include<math.h>

#define pi 3.141592653589793

double sqr(double x)
{
	return x*x;
}

int main()
{
	double x1,y1,x2,y2,x3,y3,a,b,c,r;
	while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF)
	{
		a=sqr(x1-x2)+sqr(y1-y2);
		b=sqr(x1-x3)+sqr(y1-y3);
		c=sqr(x2-x3)+sqr(y2-y3);
		r=sqrt(c/4/(1-sqr(a+b-c)/4/a/b));
		printf("%.2lf\n",2*pi*r);
	}
	return 0;
}
Time Limit 1 second
Memory Limit 32 MB
Discuss Stats
上一题 下一题