游客 Signup | Login
中文 | En

2177 - 威力强大的silkay和她研制的炸弹

silkay研究出了一种新型炸弹,这种炸弹的特点是:炸弹能量可以在爆炸之前进行调节。
silkay制造了三个新型炸弹,她选了一片空地进行炸弹的爆炸测试。silkay选好了三个炸弹爆炸的地点,为了节省时间,silkay决定同时引爆三个炸弹。但是一方面,silkay希望能激发炸弹最大的能量(使三个炸弹的能量之和最大),另一方面,炸弹彼此之间不能相互影响。那么如何调节每一个炸弹的能量,才能完成这次爆炸测试呢?(炸弹的爆炸范围是一个圆,我们用该圆的半径来衡量炸弹爆炸的能量)

<br />

Input

输入包含多组测试数据
每组测试数据包括三行,每行两个整数x, y,代表相应的炸弹引爆的地点坐标 (|x| <= 1000 |y| <= 1000)
三个坐标不在同一条直线上

Output

每组测试数据输出三行,每行一个实数,代表相应炸弹引爆范围的圆的半径(输出保留整数)

Examples

Input

0 0
4 0
4 3

Output

3
1
2

Solution C++

#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;

double dis(double a, double b, double c, double d) {
  return sqrt((a - c) * (a - c) + (b - d) * (b - d));
}
int main() {
	//freopen("Problem2.in", "r", stdin);
	//freopen("Problem2.out", "w", stdout);
  double x1, x2, x3, y1, y2, y3;
  double d1, d2, d3, r1, r2, r3;
  while (scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3) !=
         EOF) {
    d1 = dis(x1, y1, x2, y2);
    d2 = dis(x2, y2, x3, y3);
    d3 = dis(x1, y1, x3, y3);
    r1 = (d3 + d1 - d2) / 2;
    r2 = (d1 + d2 - d3) / 2;
    r3 = (d2 + d3 - d1) / 2;
    printf("%.0lf\n", r1);
    printf("%.0lf\n", r2);
    printf("%.0lf\n", r3);
  }
  return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题