很容易就想到把三维转化成了二维,求出点离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的更多相关文章

  1. HDU 3756 Dome of Circus

    不会做,参见别人的程序: /* 底面为xy平面和轴为z轴的圆锥,给定一些点,使得圆锥覆盖所有点并且体积最小 点都可以投射到xz平面,问题转换为确定一条直线(交x,z与正半轴)使得与x的截距r 和与z轴 ...

  2. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  3. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. luogu2261 [CQOI2007] 余数之和

    题目大意 求 \[\sum_{i=1}^{n}(k\mod i)\] \(n,k\leq 10^9\). 题解 先只考虑\(n\leq k\)的情况. \[\sum_{i=1}^{n}(k\mod i ...

  2. Windows 平台下 Go 语言的安装和环境变量设置

    1. Go 语言 SDK 安装包下载和安装 最新稳定版 1.5.3 安装包 go1.5.3.windows-amd64.msi下载地址 https://golang.org/dl/,大小约 69 MB ...

  3. [hihicoder][Offer收割]编程练习赛47

    删除树节点 #pragma comment(linker, "/STACK:102400000,102400000") #include<stdio.h> #inclu ...

  4. 利用a链接发送电子邮件

    实例代码: <a href="mailto:name1@rapidtables.com?cc=name2@rapidtables.com&subject=你好%20我是&quo ...

  5. javascript中经典继承的兼容写法

    function create(obj) { // 2.1 判断浏览器支持不支持 Object.create // 如果支持,直接使用 Object.create // 如果不支持,自己实现 if(O ...

  6. css 中font属性知识点总结

    一. font属性值可以继承.例如子元素可以继承父元素的行高,字体大小等等. 二.font属性可以进行连写:font: font-sytle  font-weight  font-size/line- ...

  7. 关于出现Failed to instantiate SLF4J LoggerFactory问题原因,解决办法

    在创建spring boot 文档进行配置的时候,因为使用spring boot 父级依赖的版本 <artifactId>spring-boot-starter-parent</ar ...

  8. boost的单例模式

    template <typename T> struct singleton_default {   private:     struct object_creator     {    ...

  9. Swift 字典 Dictionary基本用法

    import UIKit /* 字典的介绍 1.字典允许按照某个键访问元素 2.字典是由两部分组成, 一个键(key)集合, 一个是值(value)集合 3.键集合是不能有重复的元素, 值集合可以有重 ...

  10. C# dataGridView1 添加数据 和清空数据

    #region MyRegion DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); DataGridViewTextBo ...