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. jmeter 实现登录一次,多次操作登录后的某一个功能

  2. C++重写(override)、重载(overload)、重定义(redefine)以及虚函数调用

    一.基本概念 对于C++中经常出现的函数名称相同但是参数列表或者返回值不同的函数,主要存在三种情况: 1.函数重写(override) 函数重载主要实现了父类与子类之间的多态性,子类中定义与父类中名称 ...

  3. [自制操作系统] 图形界面&VBE工具&MMIO显存&图形库/字库

    本文记录了在JOS(或在任意OS)上实现图形界面的方法与一些图形库的实现. 本文中支持的新特性: 支持基本图形显示 支持中英文显示(中英文点阵字库) 相关:VBE VESA MMIO 点阵字库 Git ...

  4. Spring MVC 解决无法访问静态文件和"全局异常处理"

    我们都知道,Spring MVC的请求都会去找controller控制器,若果我们页面中引入了一个外部样式,这样是没效果的, 我们引入样式的时候是通过<like href="...&q ...

  5. 蓝桥杯试题利用数学知识经典解法,1.三个空瓶子换一瓶水;2.猜最后一个字母——猎八哥FLY

    本博客为本人原创,转载请在醒目位置表明出处. 1.乐羊羊饮料厂正在举办一次促销优惠活动.乐羊羊C型饮料,凭3个瓶盖可以再换一瓶C型饮料,并且可以一直循环下 去,但不允许赊账.请你计算一下,如果小明不浪 ...

  6. PHP初入--表单元素

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  7. 团队作业4——第一次项目冲刺(Alpha版本) Day2

    1.Day 2 站立式会议: 2.leangoo任务分截图: 3.会议记录及任务分配: 队员 今日进展 明日安排 林燕 完善逻辑架构框架,继续学习微信开发 完成4.24随笔 王李焕 初步总结微信开发的 ...

  8. 201521123066《Java程序设计》第五周学习总结

    1. 本周学习总结 1.1 尝试使用思维导图总结有关多态与接口的知识点. 2. 书面作业 1代码阅读:Child压缩包内源代码 1.1 com.parent包中Child.java文件能否编译通过?哪 ...

  9. 201521123060 《Java程序设计》第3周学习总结

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

  10. 201521123061 《Java程序设计》第一周学习总结

    1.本周学习总结 (1) Java的来历与版本演进 最早是Sun公司绿色项目Green Project 中所撰写的Strar7应用程序的程序语言: (2)Java根据应用领域分为三大平台:Java S ...