HDU 3756
很容易就想到把三维转化成了二维,求出点离Z轴的距离,把这个距离当成X坐标,Z轴当Y坐标,然后就变成了求一个直角三角形覆盖这些点
像上一题一样,确定斜率直线的时候,必定是有一点在线上的。于是,可以把直线看成垂直X轴,按角度旋转点即可。
也有二分高度的做法。
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std; struct Point{
double x,y;
};
Point point[10050];
int n;
const double PI=3.141592653;
const double inf=1e10;
double ansx,ansh;
double cal(double ang){
double cs=cos(ang),sn=sin(ang);
double x;
double xmax=-inf;
for(int i=1;i<=n;i++){
x=cs*point[i].x-sn*point[i].y;
xmax=max(xmax,x);
}
ang=-ang;
cs=cos(ang),sn=sin(ang);
ansx=xmax/cs;
ansh=xmax/sn;
return ansx*ansx*PI*ansh/3;
} int main(){
int T;double x,y,z;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%lf%lf%lf",&x,&y,&z);
point[i].y=z;
point[i].x=sqrt(x*x+y*y);
}
double l=-90*PI/180,r=0; double m,mm;
while(l+(1e-8)<r){
m=l+(r-l)/3;
mm=r-(r-l)/3;
if(cal(m)>cal(mm))
l=m;
else r=mm;
}
cal(l);
printf("%.3lf %.3lf\n",ansh,ansx);
}
return 0;
}
HDU 3756的更多相关文章
- HDU 3756 Dome of Circus
不会做,参见别人的程序: /* 底面为xy平面和轴为z轴的圆锥,给定一些点,使得圆锥覆盖所有点并且体积最小 点都可以投射到xz平面,问题转换为确定一条直线(交x,z与正半轴)使得与x的截距r 和与z轴 ...
- HDU题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
随机推荐
- 【C语言】编写函数,将一个数的指定位置置0或置1
//编写函数,将一个数的指定位置置0或置1 #include <stdio.h> unsigned int set_bit(unsigned int num, int pos, int f ...
- js中简单操作
去空格:ss.replace(/\s/g,""); 数组: 千万不能用in操作符 in 是说存不存在这个key而不是value! var a = [66,99,77]; 66 in ...
- nyoj--92--图像有用区域(模拟)
图像有用区域 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 "ACKing"同学以前做一个图像处理的项目时,遇到了一个问题,他需要摘取出图片中某个黑 ...
- [HTML] 条件注释判断浏览器
<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--><!--[if IE]> 所有的IE可识别 <![e ...
- JS 中构造函数和普通函数的区别(详)
1.构造函数也是一个普通函数,创建方式和普通函数一样,但构造函数习惯上首字母大写 2.构造函数和普通函数的区别在于:调用方式不一样.作用也不一样(构造函数用来新建实例对象) 3.调用方式不一样. 普通 ...
- C++ 类型转换操作与操作符重载 operator type() 与 type operator()
类型转换操作符(type conversion operator)是一种特殊的类成员函数,它定义将类类型值转变为其他类型值的转换.转换操作符在类定义体内声明,在保留字 operator 之后跟着转换的 ...
- c# 异步任务队列(可选是否使用单线程执行任务,以及自动取消任务)
使用demo,(.net framework 4.0 自行添加async wait 扩展库) class Program { static void Main(string[] args) { Con ...
- 「图解HTTP 笔记」Web 基础
Web 基础 三项构建技术: HTML:页面的文本标记语言 HTTP:文档传输协议 URL:指定文档所在地址 一些概念 HTTP(HyperText Transfer Protocol):通常被译为& ...
- UML+模式设计概述
转自于:http://blog.csdn.net/rexuefengye/article/details/13020225 工程学:工程庞大到一定程度必须是用工程学方法,好比直接用水泥沙子建设实用的摩 ...
- sql 查询多列 小于某值
select COUNT(*) from ( select ID,H1 AS Value from Table_1 union all select ID,H2 from Table_1 union ...