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. web安全普及:通俗易懂,如何让网站变得更安全?以实例来讲述网站入侵原理及防护。

    本篇以我自己的网站[http://www.1996v.com]为例来通俗易懂的讲述如何防止网站被入侵,如何让网站更安全. 要想足够安全,首先得知道其中的道理. 本文例子通俗易懂,从"破解网站 ...

  2. webpack常见的配置总结 ---只是一些常见的配置

    早期的构建工具grunt ,gulp 帮助我们配置一些开发环境,省去一些我们调试和重复的工作 现在我们的构建工具一般是webpack ,目前建议大家用3.0以上的版本 现在市场上比较优秀的构建工具,个 ...

  3. win10下移动硬盘位置不可用无法访问

    win10下移动硬盘位置不可用无法访问 网上搜索得到的答案是: 请参考以下步骤解决: 1.按Windows+R输入"CHKDSK H: /F /R"(H:是硬盘所在盘符./R 找到 ...

  4. 深入理解JVM(八)——java堆分析

    上一节介绍了针对JVM的监控工具,包括JPS可以查看当前所有的java进程,jstack查看线程栈可以帮助你分析是否有死锁等情况,jmap可以导出java堆文件在MAT工具上进行分析等等.这些工具都非 ...

  5. Python输入输出练习,运算练习,turtle初步练习

    Hello World! 简单交互(交互式,文件式)教材P19 radius=25 area=3.1415*radius*radius print(area) print('{:.2f}'.forma ...

  6. 【2017集美大学1412软工实践_助教博客】团队作业7——Alpha冲刺之事后诸葛亮

    题目 团队作业7: http://www.cnblogs.com/happyzm/p/6827853.html 团队成绩 评分项目 变更管理 设计/实现 测试/发布 团队的角色,管理,合作 总结 全组 ...

  7. 如何让eclipse在程序修改后,点击运行可以自动保存。

    preferences>run/debug>launching里面save required dirty editors before launching选always就自动保存咯选pro ...

  8. 201521123065 《Java程序设计》第5周学习总结

    1. 本周学习总结 1.1 尝试使用思维导图总结有关多态与接口的知识点. 1.2 可选:使用常规方法总结其他上课内容. 1.ArrayList只能存放对象: 2.对象包装类之间使用equals进行比较 ...

  9. 201521123011 《Java程序设计》 第三周学习总结

    1. 本周学习总结 2. 书面作业 1.代码阅读 public class Test1 { private int i = 1;//这行不能修改 private static int j = 2; p ...

  10. 我的Emacs配置文件

    (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you co ...