hrbust 2354 An Easy Geometry Problem

An Easy Geometry Problem
Time Limit: 1000 MSMemory Limit: 262144 K
Total Submit: 52(25 users)Total Accepted: 19(16 users)Rating: Special Judge: No
Description

Lily is interested in hyperspace recently, and she is trying to solve an easy problem now. Given an n-dimensional hyperspace, assuming each dimension is a1, a2, a3, ..., an. And for each i (1 ≤ ≤ n), j (i < j ≤ n), there is a plane ai=aj  These planes have divided the hyperspace into different regions. For example, in 3D hyperspace, we have three planes: x=y, y=z and x=z.

Now given q queries, for each query, there is a point (x1, x2, x3, ..., xn). Lily wants to know the maximum radius r of an n-dimensional ball she can put in point (x1, x2, x3, ..., xn), which means the center of the ball is in point (x1, x2, x3, ..., xn) and the ball’s surface cannot cross but can touch any planes mentioned above.

The equation of an n-dimensional ball with center (x1, x2, x3, ..., xn) is . And the distance between two points (x1, x2, x3, ..., xn) and (x1', x2', x3', ..., xn') in an n-dimensional hyperspace is:.

Input

First line contains an integer T (1 ≤ ≤ 5), represents there are T test cases.

For each test case: First line contains two integers n (3 ≤ ≤ 50000) and q (1 ≤ ≤ 8), where n is the dimension of the hyperspace, and q is the number of queries. Following q lines, each line contains n integers x1, x2, x3, ..., xn (-109 ≤ xi ≤ 109), represents the coordinate of the balls center.

Output

For each test case, output one line containing "Case #X:"(without quotes), where X is the case number starting from 1, and output q lines containing the maximum possible radius of the ball in each query in input order, rounded to four decimal places.

Sample Input

1

3 2

0 0 0

11 22 33

Sample Output

Case #1:

0.0000

7.7782


Source
“科林明伦杯”哈尔滨理工大学第七届程序设计团队赛

读题两小时实现5分钟。


最大圆半径。(满足  These planes have divided the hyperspace into different regions. For example, in 3D hyperspace, we have three planes: x=y, y=z and x=z


转化成2维直接找到规律。

#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define N 100005
int T;
double r[N];
int main()
{
    scanf("%d",&T);
    int icase=0;
    while(T--){
        int n,m;
        printf("Case #%d:\n",++icase);
        scanf("%d%d",&n,&m);
        while(m--){
            for(int i=0;i<n;i++){
                scanf("%lf",&r[i]);
            }
            sort(r,r+n);
            double res = 1e15;
            for(int i=1;i<n;i++){
                res = min(res,r[i]-r[i-1]);
            }
            printf("%.4f\n",res/sqrt(2.0));
        }
    }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值