Dome of Circus

Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 937    Accepted Submission(s): 420 Special Judge

Problem Description
A travelling circus faces a tough challenge in designing the dome for its performances. The circus has a number of shows that happen above the stage in the air under the
dome. Various rigs, supports, and anchors must be installed over the stage, but under the dome. The dome itself must rise above the center of the stage and has a conical
shape. The space under the dome must be air-conditioned, so the goal is to design the dome that contains minimal volume. You are given a set of n points in the space;
(xi, yi, zi) for 1 ≤ i ≤ n are the coordinates of the points in the air above the stage that must be covered by the dome. The ground is denoted by the plane z = 0, with
positive z coordinates going up. The center of the stage is on the ground at the point (0, 0, 0). The tip of the dome must be located at some point with coordinates (0, 0, h)
with h > 0. The dome must have a conical shape that touches the ground at the circle with the center in the point (0, 0, 0) and with the radius of r. The dome must contain
or touch all the n given points. The dome must have the minimal volume, given the above constraints.
 
Input
The input begins with an integer T. The next T blocks each represents a case. The first line of each case contains a single integer number n (1 ≤ n ≤ 10 000) - the number
of points under the dome. The following n lines describe points with three floating point numbers xi, yi, and zi per line - the coordinates of i-th point. All coordinates do
not exceed 1000 by their absolute value and have at most 2 digits after decimal point. All zi are positive. There is at least one point with non-zero xi or yi.
 
Output
For each case , write to the output file a single line with two floating point numbers h and r - the height and the base radius of the dome. The numbers must be precise up
to 3 digits after decimal point.
 
Sample Input
3
1
1.00 0.00 1.00
2
1.00 0.00 1.00
0.00 1.50 0.50
3
1.00 0.00 1.00
0.00 1.50 0.50
-0.50 -0.50 1.00
 
Sample Output
3.000 1.500
2.000 2.000
2.000 2.000
 

一道几何三分题,其实三分和二分差不多,懂三分算法就挺简单的

 #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <stack>
using namespace std;
#define ll long long int
#define INF 0.0001
#define PII 3.1415926535898
int m;
double a[][];
double fun(double x)
{
int i;
double r=(x*sqrt(a[][]*a[][]+a[][]*a[][]))/(x-a[][]);
for(i=;i<m;i++)
{
if(r<(x*sqrt(a[i][]*a[i][]+a[i][]*a[i][]))/(x-a[i][]))
r=(x*sqrt(a[i][]*a[i][]+a[i][]*a[i][]))/(x-a[i][]);
}
return r;
}
int main()
{
cin>>m;
int j;
double low=-;
for(j=;j<m;j++)
{
cin>>a[j][]>>a[j][]>>a[j][];
if(low<a[j][])
low=a[j][];
}
double hight=20000.0;
double x,y,rx,ry;
while(hight-low>INF)
{ x=(hight-low)/+low;
y=low+*(hight-low)/;
rx=fun(x);
ry=fun(y);
if(PII*rx*rx*x/>PII*ry*ry*y/)
{
low=x;
}
else
{
hight=y;
}
}
printf("%.3lf %.3lf\n",hight,ry);
return ;
}

hdu3756三分基础题的更多相关文章

  1. Android测试基础题(三)

    今天接着给大家带来的是Android测试基础题(三).    需求:定义一个排序的方法,根据用户传入的double类型数组进行排序,并返回排序后的数组 俗话说的好:温故而知新,可以为师矣 packag ...

  2. 小试牛刀3之JavaScript基础题

    JavaScript基础题 1.让用户输入两个数字,然后输出相加的结果. *prompt() 方法用于显示可提示用户进行输入的对话框. 语法: prompt(text,defaultText) 说明: ...

  3. 小试牛刀2:JavaScript基础题

    JavaScript基础题 1.网页中有个字符串“我有一个梦想”,使用JavaScript获取该字符串的长度,同时输出字符串最后两个字. 答案: <!DOCTYPE html PUBLIC &q ...

  4. HDU 1301 Jungle Roads (最小生成树,基础题,模版解释)——同 poj 1251 Jungle Roads

    双向边,基础题,最小生成树   题目 同题目     #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include<stri ...

  5. nyist oj 79 拦截导弹 (动态规划基础题)

    拦截导弹 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描写叙述 某国为了防御敌国的导弹突击.发展中一种导弹拦截系统.可是这样的导弹拦截系统有一个缺陷:尽管它的第一发炮弹可以 ...

  6. linux面试题-基础题1

    第1章 基础题1 1.1 在装系统创建Linux分区时,一般至少需要创建两个分区( ) A.FAT.NTFS   B. /usr.swap    C. /boot.swap  D.swap./ 1.2 ...

  7. Java面试题以及答案精选(架构师面试题)-基础题1

    基础题 一.String,StringBuffer, StringBuilder 的区别是什么?String为什么是不可变的?1. String是字符串常量,StringBuffer和StringBu ...

  8. C++笔试题2(基础题)

    温馨提醒:此文续<C++笔试题(基础题)> (112)请写出下列程序的输出内容 代码如下: #include <iostream> using namespace std; c ...

  9. C/C++笔试题(基础题)

    为了便于温故而知新,特于此整理 C/C++ 方面相关面试题.分享,共勉. (备注:各题的重要程度与先后顺序无关.不断更新中......欢迎补充) (1)分析下面程序的输出(* 与 -- 运算符优先级问 ...

随机推荐

  1. python3 安装及项目管理安装

    python3 一.下载安装 地址:https://www.python.org/downloads/ 安装:傻瓜式安装:我的目录如下 二.环境配置 [右键计算机]-->[属性]-->[高 ...

  2. H5性能测试学习

    工欲善其事,必先利其器,在做H5前端性能测试之前,选择合适的工具能让我们的测试工作事半功倍.本文要提到的工具有两类: 一类是抓包工具,如Fiddler.Charles等.这类工具不仅可以抓包,还可以对 ...

  3. element-ui更换主题色

    1.cd到你的项目文件目录下,npm i element-theme -g 2.npm i element-theme-default -D 3.et -i 执行后当前目录会有一个 element-v ...

  4. Java线程:线程栈模型

    要理解线程调度的原理,以及线程执行过程,必须理解线程栈模型. 线程栈是指某时刻时内存中线程调度的栈信息,当前调用的方法总是位于栈顶.线程栈的内容是随着程序的运行动态变化的,因此研究线程栈必须选择一个运 ...

  5. JSONP的实现流程

    在进行AJAX的时候会经常产生这样一个报错: 看红字,这是浏览器的同源策略,使跨域进行的AJAX无效.注意,不是不发送AJAX请求(其实就是HTTP请求),而是请求了,也返回了,但浏览器‘咔擦’一声, ...

  6. 团队作业8——第二次项目冲刺(Beta阶段)

    Deadline: 2017-5-28 22:00PM,以博客发表日期为准 评分基准: 按时交 - 有分,检查的项目包括后文的三个个方面 冲刺计划安排(单独1篇博客) 七天的敏捷冲刺(每天发布1篇,共 ...

  7. JAVA基础第六组(5道题)

    26.[程序26] 题目:请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续 判断第二个字母.         1.程序分析:用情况语句比较好,如果第一个字母一样,则判断用情况语句 ...

  8. 团队作业7——Alpha冲刺之事后诸葛亮(宣告项目失败团队解散)

    一.项目进度 1.4月5日,团队组建.满怀希望的能做好这个项目 2.4月12日,需求分析. 3.4月21日,需求改进,出现协作问题,没有做好. 4.做项目,学习新的知识,继续做项目,但是能力有限,团队 ...

  9. Beta阶段冲刺日志集合贴

    [Beta]Daily Scrum Meeting--Day1:http://www.cnblogs.com/RunningGuys/p/6890738.html [Beta]Daily Scrum ...

  10. 201521123052《Java程序设计》第1周学习总结

    1. 本周学习总结 1.认识Java,了解JVM.JRE与JDK,并下载与安装JDK: 2.设置好eclipse并使用eclipse完成简单的Java编程: 3.使用博客.码云与PTA,这些对Java ...