acm - 1640. Circle of Winter 最为简单的形式- 构造解 非最优解


原链接: http://acm.timus.ru/problem.aspx?space=1&num=1640

1640. Circle of Winter

Time limit: 1.0 second
Memory limit: 64 MB
Lich Sandro declared war to the King of Hell, and now hordes of demons are fighting fiercely against Sandro's army of the undead. Sandro has mastered the Magic of Fire, but the creatures of Hell can't be damaged by fire. That's why Sandro decided to use a “Circle of Winter” spell against them. This spell creates an indestructable circular-shaped ice wall. The demons who are touched by the circumference die immediately; the demons enclosed in a circle stay alive, but can't participate in the fight anymore.
Sandro can teleport to any point of the battlefield instantly and cast a “Circle of Winter” there. An ice wall centered in that point will appear in that case. Note that Sandro's magic skills allow him to cast a wall with a radius not exceeding 10000 metres. Now Sandro wants to choose a point to teleport to and a radius of a spell in such way that at least one demon would be killed and all the rest would be enclosed in a circle.

Input

The first line contains an integer  n — the number of demons  (1 ≤  n ≤ 100) . Demons can be considered as points on the battlefield. The next  n lines contain  n pairs of space-separated integers ( xy) — the coordinates of the demons relative to the point Sandro occupies before teleportation. Coordinates are given in metres and don't exceed 1000 in absolute value. Each point of the battlefield contains no more than one demon; also a demon can't occupy a point the Sandro occupies before teleportation.

Output

Output 3 real numbers precise up to 10 −9 — the coordinates of a point Sandro should teleport to and the radius of a “Circle of Winter” he should create. Sandro can't teleport to a point that is occupied by a demon. It is guaranteed that the solution always exists.

Samples

input output
7
1 1
1 5
3 6
5 3
8 0
9 5
5 9
5 4 5
2
0 2
2 0
1 1 1.41421356237309
Problem Author: Dmitry Ivankov (prepared by Alexander Ipatov)
Problem Source: USU Junior Contest, October 2008
Tags:  geometry  



#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define maxn 105
const double eps = 1e-9;
double x[maxn],y[maxn],cx,cy,r;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0;i < n;i++)
        scanf("%lf %lf",&x[i],&y[i]);
    cx = cy = 0.1;
    r = 0.0;
    for(int i = 0;i < n;i++)
        r = max(r,sqrt((cx - x[i]) * (cx - x[i]) + (cy - y[i]) * (cy - y[i])));
    printf("%.10lf %.10lf %.10lf\n",cx,cy,r);
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值