hrbust 2354 An Easy Geometry Problem
来源:互联网 发布:json remove key 编辑:程序博客网 时间:2024/05/02 00:35
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 ≤ i ≤ 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:.
InputFirst line contains an integer T (1 ≤ T ≤ 5), represents there are T test cases.
For each test case: First line contains two integers n (3 ≤ n ≤ 50000) and q (1 ≤ q ≤ 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 ball’s center.
OutputFor 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 Input1
3 2
0 0 0
11 22 33
Sample OutputCase #1:
0.0000
7.7782
Source“科林明伦杯”哈尔滨理工大学第七届程序设计团队赛
读题两小时实现5分钟。
最大圆半径。(满足j 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 100005int 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)); } }}
- hrbust 2354 An Easy Geometry Problem
- An Easy Problem
- 2055 An easy problem
- An Easy Problem!
- An Easy Problem!
- poj2826 An Easy Problem?!
- HDOJ2055 An easy problem
- An Easy Problem
- hdu-An Easy Problem
- hdu2601 An easy problem
- An Easy Problem
- hdu-An Easy Problem
- HDU_2055 An easy problem
- HDU_2123 An easy problem
- B - An easy problem
- B - An easy problem
- An easy problem
- An easy problem 2132
- java程序员面试题之32问
- 笔记(5)
- Hadoop RPC实战
- CapsNet
- Font Awesome(六)
- hrbust 2354 An Easy Geometry Problem
- 分治---线性时间选择
- retrain tensorflow中InceptionV3模型
- 如何让opencv成为MATLAB中的一个工具箱
- 重识java11
- python-基础知识-20171219
- Gainlo 面试指南 翻译完成
- 嵌入式名词以及简略说明
- 【Luogu2711】小行星(网络流,最大流)