很容易就想到把三维转化成了二维,求出点离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. [Linux]RedHat Linux 忘记rootpassword该怎样又一次设置password

    1. 开机在出现grub画面,按e键,例如以下图所看到的: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvU3VubnlZb29uYQ==/font/5a6 ...

  2. luogu3911 最小公倍数之和

    题目大意 给出一些数\(A_1,A_2,\cdots A_n\),求 \[\sum_{i=1}^{n}\sum_{j=1}^{n}\mathrm{lcm}(A_i,A_j)\] \(A_i,A_n\l ...

  3. 【转】In ASP.NET using jQuery Uploadify upload attachment

    Upload Uploadify is a JQuery plug-in, achieve the effect is very good, with progress display. Upload ...

  4. 使用ssh和putty操控远程的linux server

    windows下没有openssh,今天这里使用openssh-server作为server,windows下使用putty作为client, putty主要流程分以下几步: step 1: 下载pu ...

  5. 文档控件NTKO OFFICE 详细使用说明之预览Excel文件(查看、编辑、保存回服务器)

    1.在线预览Excel文件 (1) 运行环境 ① 浏览器:支持IE7-IE11(平台版本还支持Chrome和Firefox) ② IE工具栏-Internet 选项:将www.ntko.com加入到浏 ...

  6. 代码实现wordpress彩色标签云的最简单的方法

    首先在wordpress主题文件夹内找到并用编辑器打开 functions.php 文件,随意找个位置不到插到别的函数里,“?>” 之前加入以下代码: //彩色标签云 function colo ...

  7. 利用JavaScript制作简易日历

    <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <met ...

  8. 整理Py小demo

    from email.mime.text import MIMEText # 第一个参数就是邮件正文,第二个参数是MIME的subtype, # 传入'plain'表示纯文本,最终的MIME就是'te ...

  9. linux openSSL 安装

    包名:openssh-server apt安装:apt-get install openssh-server yum安装:yum install openssh-server 服务启动:service ...

  10. Eigen库对齐问题:declspec(align('16')) 的形参将不被对齐

    一:错误提示:error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned 英文提示:erro ...