【三分】HDU3756 Dome of Circus

DELL服务器BIOS下配置RAID阵列 dell服务器配置raid阵列 阅读详情
  • 假设我们枚举一个半径r,那么分别考虑包含进每个点圆锥的最小高度h0,h1,…,hn−1,显然此时如果半径为r,圆锥高度应为maxn−1i=0 hi,简单推算一下公式,可以发现体积关于半径是个凹函数,于是三分半径即可。
  • 注意初始的半径范围,上限自然可以随便设置一个较大值,但下限需要稍加考虑。设
    di=xi2+yi2−−−−−−−√
    那么r应满足
    r>max{di},0≤i<n
  • 输入输出部分,即使ios::sync_with_stdio(false)也无法避免cin和cout的超时问题,所以似乎必须用printf和scanf来IO。
/* **********************************************

    File Name: 3756.cpp

    Auther: zhengdongjian@tju.edu.cn

    Created Time: 2015/9/9 星期三 下午 7:07:06

*********************************************** */
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const double EPS = 1e-4;
const double INF = (double)INT_MAX;
const int MAX = 10007;
struct Pos {
    double x, y, z;
} a[MAX];
int n;

istream& operator>>(istream& in, Pos& p) {
    in >> p.x >> p.y >> p.z;
    return in;
}

pair<double, double> gao(double r) {
    double h = 0.0;
    for (int i = 0; i < n; ++i) {
        double dis = a[i].x * a[i].x + a[i].y * a[i].y;
        dis = sqrt(dis);
        //printf("dis = %f\n", dis);
        //getchar();
        double tp = a[i].z / (r - dis) * dis + a[i].z;
        if (tp > h) h = tp;
    }
    return make_pair(h, r * r * h);
}

pair<double, double> cut(double le, double ri) {
    double md, mdmd;
    while (ri - le > EPS) {
        //printf("le = %f, ri = %f\n", le, ri);
        md = (le + ri) * 0.5;
        mdmd = (md + ri) * 0.5;
        if (gao(mdmd).second > gao(md).second) {
            ri = mdmd;
        } else {
            le = md;
        }
    }
    //printf("le = %f, ri = %f\n", le, ri);
    return make_pair(gao(le).first, le);
}

int main() {
    int T;
    scanf(" %d", &T);
    while (T--) {
        scanf(" %d", &n);
        double mindis = 0.0;
        for (int i = 0; i < n; ++i) {
            scanf(" %lf %lf %lf", &a[i].x, &a[i].y, &a[i].z);
            mindis = min(mindis, sqrt(a[i].x * a[i].x + a[i].y * a[i].y));
        }
        //auto res = make_pair(0.0, 0.0);
        auto res = cut(mindis + EPS, 100000.0);
        printf("%.3f %.3f\n", res.first + EPS, res.second + EPS);
    }
    return 0;
}
BAPI_OUTB_DELIVERY_CHANGE扩展指南:利用EXTENSION2与SMOD_V50B0001实现自定义字段更新 本文详细解析了如何利用BAPI_OUTB_DELIVERY_CHANGE的EXTENSION2参数与增强点SMOD_V50B0001,在不修改标准代码的前提下,安全、标准地更新SAP交货单的自定义字段。通过清晰的步骤指南和实战代码示例,帮助开发者掌握通过增强字段实现定制化业务需求的完整流程与调试技巧。 阅读详情

相关推荐

知识的定义与分类体系详解 - 从零基础到专业理解

知识的定义与分类体系详解 - 从零基础到专业理解

engchina的专栏 4430

HDU Dome of Circus

#include #include #include #include #include #include #include #include #include //#include "myAlgorithm.h" #define MAX 10005 #define INF (1e8 + 5) #define eps 1e-7 #define Rep

极度猥琐 939

命名管道和匿名管道

我们知道进程间是可以通信的。可以达到数据传输、资源共享、事件通知、进程控制等目的。进程间通信主要包括管道、系统IPC,套接字等。 管道分为三种: 普通管道:一是单工,只能单向传输 ,二是仅能在父子进程或者兄弟进程中使用。 流管道:去除了第一种限制,为半双工,可以双向传递, 命名管道:去除了第二种限制 ,可以在很多并不相关的进程 中进行通信。 1、普通管道 int pipe(int f...

ffsiwei的博客 1万+

HDU 3756 Dome of Circus(计算几何 + 三分)

题意:给定三维空间中n个点坐标,必在xOy平面之上,求一个最小的圆锥能包含所有顶点,点可以刚好在面上 思路:转换为平面上的点被一个三角形包围,Y坐标为原来的z坐标,X坐标为原来到z轴的距离,然后三分求解斜率,注意精度问题 #include #include #include #include #include #include #include #include #include #inclu

hnust_Derker的博客 397

浅谈MOS管的发热原因和解决办法

解读一下开关管发热原因,解决方案和开关损耗测试。

qq_45508321的博客 1万+

QtWebApp的使用【在Qt中搭建HTTP服务器】(一)

用Qt和QtWebApp能够实现在C++中开发HTTP Web服务器应用程序。 首先,需要先安装Qt的软件开发工具包。点此下载 其次,下载最新的QtWebApp库。点此下载 下载并解压缩QtWebApp ZIP文件。你将会看到: 如何使用QtWebApp 1)将QtWebApp.zip文件解压到文件夹中,并创建一个名为“ MyFirstWebApp”的新Qt控制台项目。然后,建立如下文件结构: 2)将以下行添加到MyFirstWebApp项目的项目文件中: QT += network include(

饭的笔记本 2万+

uva 1473 - Dome of Circus (几何 + 二分)

题目链接:uva 1473 - Dome of Circus #include #include #include #include using namespace std; const int maxn = 10005; const double inf = 0x3f3f3f3f3f3f3f3f; const double eps = 1e-9; struct Poin

不慌不忙、不急不躁 846

【谷粒商城】分布式事务与下单

=购物车== 构建gulimall-cart,复制静态资源到nginx,修改网关 购物车分为离线购物车和登录购物车 离线购物车重启浏览器了也还有 1、购物车需求 特点:读多写少,放入数据库并不合适 登录状态:登录购物车 放入数据库 mongodb 放入redis(采用) 登录以后,将离线购物车里合并后清空离线购物车 未登录状态:离线购物车 放入localstorage浏览器的技术 cookie WebSQL 放入redis(采用) 浏览器重启后还在 2、购物车VO (1) 数据结构分析

努力充实,远方可期 1万+

HDU 3756 Dome of Circus 三分

/* 底面为xy平面和轴为z轴的圆锥,给定一些点,使得圆锥覆盖所有点并且体积最小 点都可以投射到xz平面,问题转换为确定一条直线(交x,z与正半轴)使得与x的截距r 和与z轴的截距h满足h*r*r最小。 三分,对于确定的h可以找到最佳的r,并且h*r*r的曲线必定只有一个极小值 */ struct po { double x,y; }p[10005]; const double eps=1

Join Hands 1921

科研神器: 用Gemini 3

Edge藏了个科研开挂神器!免TZ/免谷歌账号用Gemini 3,1分钟上手(附保姆级教程) 做科研查文献、理数据总卡壳?想蹭Gemini 3的AI能力,却被“谷歌账号+TZ+节点筛选”三连劝退? 现在不用折腾了!Edge浏览器里装个插件,直接把Gemini 3揣进口袋——**免翻墙、免谷歌账号、国内直接用**,分分钟让你的科研效率翻三倍,导师都得问你“偷偷开了啥挂”!

ZhangJiqun&191cm&85kg 1171

Proteus8.0仿真应用设计(九十一)基于STM32CubeMX、STM32F103C8T6 、FREERTOS、MCP41010(SPI接口)的8位数字电位器应用设计仿真

MCP41010是一款SPI接口的8位数字电位器。

zhusl6688的博客 562

hdu 3756 Dome of Circus(三分)

题意:求能将所有点覆盖的最小体积的圆锥。 体积变化为凹形,故可以三分半径r,再枚举各个点找最大的高h。 View Code 1 /* 2 Author:Zhaofa Fang 3 Lang:C++ 4 */ 5 #include <cstdio> 6 #include <cstdlib> 7 #include <sstr...

diaoqisi8354的博客 153

使用 MATLAB/Simulink + Simscape Electrical 来构建一个CCHP微电网与新能源协同运行的模型

随着能源需求的增长和对环境保护要求的提高,冷热电联供(Combined Cooling, Heating and Power, CCHP)系统作为一种高效的分布式能源解决方案,越来越受到关注。CCHP系统通过利用一次能源同时产生电力、制冷和供热,实现了能源的梯级利用,提高了能源使用效率。结合太阳能、风能等可再生能源,可以进一步增强系统的灵活性和环保性。本文将详细介绍如何使用来构建一个CCHP微电网与新能源协同运行的模型,并通过仿真分析其性能表现。本文介绍了如何使用构建一个。

xiaoheshang_123的博客 145

hdu 3756 Dome of Circus 三分

hdu 3756 Dome of Circus 题意: 在一个三维空间中, 给定一些点, 这些点的z坐标都是大于0的。要求求出一个圆锥(底面是圆形), 使得这个圆锥的底面在z = 0的平面上, 它能够包含所有给定的n个点并且圆锥的体积要求最小。 限制: 1 |x|, |y|, |z| 思路: 先把所有点映射到一个X-Y坐标的第一象限上, 然后问题就转化为, 求一条直线

whai的专栏 868

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

hdu 3756 三分 Dome of Circus

题意:        给你很多个点,让你输出一个r和h,使这样的圆锥体能覆盖给出的所有点并且体积最小。 题解:        三分(因为是个最值的问题)。枚举r,得到h。 做题过程:      wa了一两次。刚开始是因为只输出2位小数,而题目的要求是输出3位小数。后来就再也找不到错误了。 最后,在今天,将三分的上限改了一改,就A了。。。只能说,我还too young ,too simpl

Julyana_Lin_夜 781

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

HDU 3756 Dome of Circus 三分

题意:在一个三维坐标中,有n个点(x,y,z),现在要用一个圆锥曲面(z>0)去覆盖住所有的点,点在圆锥曲面上也认为是覆盖。问当z=0时,圆锥曲面的半径和当(x,y=0)时,圆锥曲面的高为多少时?圆锥曲面的体积最小。 想法:首先先看二维图,设一个线段(x,0)(x,y),如果此时在x外围处有一个点为k,那么很显然当k越接近x时,则k与(x,y)构成的之间与y轴的交点越是大。所以当我们知道

猫ER 617

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

hdu3756 Dome of Circus:三分学习

这个题虽然是三维的,但是可以很容易的转化到二维去 。来看X-Z这个平面,我们将所有的点进行圆周映射,然后将所有的点都投影到 X-Z平面的的第一象限去,然后问题就转化成了在X-Z平面上找到一条斜率为负 的直线L,L和X正方向、Z正方向围成的三角形包含所有点,如果假设L和X轴的

凌语小辉 1295

HDU 3756 && UVALive 4986 Dome of Circus Dome of Circus(计算几何基础+三分)

Sample Input 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

C_Dreamy的博客 355

LA 4986 hdu3756 Dome of Circus 三分答案

题目地址:hdu3756

Jingqi@Mr.B的ACM博客 669

HDU 3756 Dome of Circus (三分)

传送门题意很简单,就是给你N个三维坐标,要你求一个三菱锥把所有点罩进去,在边边也行,要你求出满足条件的最小体积的三菱锥的高H和底面半径R很简单三分就行了但是这题我自己当时过得很惨烈,我写搓了,结果靠交来测答案。先是我写搓的代码,给巨巨们引以为戒#include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #def

o670783915的博客 277

hdu 3756 || Dome of Circus || 2010 Northeastern European Regional Contest(三分)

题目hdu 3756 Dome of Circus连接 请搓 题意: 在建一个已原点为圆心的圆锥体。要求圆锥体要包括在给出n个在第一、二、三、四象限的所有点,并且使圆锥体体积最小,求出半径和高。 思路: 看了这个百度搜索排第一题解看懂了内容,但是这个和具体实现没太大关系,头都大了。一怒写下这个自以为比较简单粗暴的博客。 其实求最小体积,只和两个变量有关,即圆半径 r 和圆锥高 h, 而所求体积

潘帅 shuai.pan 649

HDU 3756 Dome of Circus

点击打开链接 题意: 给n 求一个全包含了所有点的最小体积锥形 解法: 把x y z映射成sqrt(x*x+y*y),z 即可转化为二维坐标 然后求一个全包含了所有点的三角形 使得底边的平方*高最小 三分高,暴力求底即可     //大白p263 #include #include #include #include #include #include #incl

Leezard's Journey 672

HDU 3756,LA 4986——Dome of Circus

题目大意:一个马戏团要建一个锥形的帐篷,

char256 777

hdu 3756 Dome of Circus(模拟退火)

Dome of Circus Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 922    Accepted Submission(s): 411 Special Judge Problem Description

街角的花街糖 910

HDU - 3756 - Dome of Circus

先上题目 Dome of Circus Time Limit: 10000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 931Accepted Submission(s): 417Special Judge Problem Description ...

weixin_30553065的博客 119

[HDU3756]Dome of Circus

题目大意:   在一个立体的空间内有n个点(x,y,z),满足z>=0。   现在要你放一个体积尽量小的圆锥,把这些点都包住。   求圆锥的高和底面半径。 思路:   因为圆锥里面是对称的,因此问题很容易可以转化到一个二维平面上,我们只需要将所有点绕着z轴旋转到xOz平面上即可。   考虑不同半径时圆锥的体积,不难发现这是一个关于半径r的下凸函数。   于是我们可以三分求解...

weixin_34349320的博客 104
上一篇: 【随便做做】Codeforces#86 Problem C Double Happiness
下一篇: 【随便做做|线段树】POJ3667 Hotel
bit_line
博客等级 码龄12年 33粉丝 150原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值