hdu 1966 Pie
Pie
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14709 Accepted Submission(s):
5209
pie. Not just one pie, no, I have a number N of them, of various tastes and of
various sizes. F of my friends are coming to my party and each of them gets a
piece of pie. This should be one piece of one pie, not several small pieces
since that looks messy. This piece can be one whole pie though.
My
friends are very annoying and if one of them gets a bigger piece than the
others, they start complaining. Therefore all of them should get equally sized
(but not necessarily equally shaped) pieces, even if this leads to some pie
getting spoiled (which is better than spoiling the party). Of course, I want a
piece of pie for myself too, and that piece should also be of the same size.
What is the largest possible piece size all of us can get? All the pies
are cylindrical in shape and they all have the same height 1, but the radii of
the pies can be different.
cases. Then for each test case:
---One line with two integers N and F with 1
<= N, F <= 10 000: the number of pies and the number of friends.
---One
line with N integers ri with 1 <= ri <= 10 000: the radii of the
pies.
possible volume V such that me and my friends can all get a pie piece of size V.
The answer should be given as a floating point number with an absolute error of
at most 10^(-3).
3 3
4 3 3
1 24
5
10 5
1 4 2 3 4 5 6 5 4 2
3.1416
50.2655
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
double a[];
double pi=3.1415926535897932;
int main()
{
int T,n,f,i; cin>>T;
while(T--)
{
cin>>n>>f;
f++;//包括我自己
double sum=;
for(i=;i<=n;i++)
{
cin>>a[i];
a[i]=a[i]*a[i];
sum=sum+a[i];
}
double l=0.0,r=sum/f;
double mid=;
while(r-l>0.000001)
{
mid=(r+l)/;
int num=;
for(i=;i<=n;i++)
{
num=num+(int)(a[i]/mid);
}
if(num>=f) l=mid;//等于号很重要
else r=mid;
}
printf("%.4lf\n",pi*mid);
}
return ;
}
hdu 1966 Pie的更多相关文章
- hdu 1969 Pie(二分查找)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1969 Pie Time Limit: 5000/1000 MS (Java/Others) Me ...
- HDU 1969 Pie(二分法)
My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N ...
- HDU 3392 Pie(DP)
题意:有一些男生女生,男生女生数量差不超过100 ,男生女生两两配对.要求求出一种配对方法,使每一对的高度差的和最小. 思路:(我是真的笨笨笨!!)设人少的一组人数为n,b[],人多的一组人数为m,g ...
- HDU 1969 Pie(二分查找)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
- HDU 1969 Pie(二分搜索)
题目链接 Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pi ...
- HDU 1969 Pie(二分,注意精度)
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- hdu 1969 Pie (二分法)
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- HDU 1969 Pie【二分】
[分析] “虽然不是求什么最大的最小值(或者反过来)什么的……但还是可以用二分的,因为之前就做过一道小数型二分题(下面等会讲) 考虑二分面积,下界L=0,上界R=∑ni=1nπ∗ri2.对于一个中值x ...
- 题解报告:hdu 1969 Pie(二分)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
随机推荐
- 《Python》 while循环、运算符和编码初识
一.while 循环 while也叫无限循环 while 条件: 循环体 判断条件: 条件为真,进入循环体,循环体执行到底部,返回,继续判断条件. 终止循环: 1.改变条件(标志位的概念) 2.bre ...
- 1.5 C++ new和delete操作符
参考:http://www.weixueyuan.net/view/6331.html 在C语言中,动态分配和释放内存的函数是malloc.calloc和free,而在C++语言中,new.new[] ...
- 正则表达式,清除HTML标签,但要保留 <br>和<img>标签,其他的清除
最近有个需求, 要替换到html当中的除了br和img以外的所有标签, 遂百度之, 在百度知道遇到大神 , 在这记录一下 /<(?!\/?br\/?.+?>|\/?img.+?>)[ ...
- magento开发中文手册
Magento开发 第一章 手册简介Introduction 对一个开发人员来说,电子商务开发也许是现今最具创造性的工作.在这个瞬息万变的网络世界,为了保持始终领先竞争对手一步,无论是对你自己还是你的 ...
- 怎么在windows7下搭建服务器
怎么在windows7系统安装IIS 图文教程 http://jingyan.baidu.com/article/1e5468f92f6e05484961b703.html 以下本人为列:第一步:先按 ...
- CentOS7安装OpenStack(Rocky版)-06.安装Neutron网络服务(控制节点)
上一章介绍了独立的nova计算节点的安装方法,本章分享openstack的网络服务neutron的安装配制方法 ------------------- 完美的分割线 ----------------- ...
- Linux服务器没有GUI的情况下使用matplotlib绘图
最近看到关于 python3 中用matplotlib 不进行交互画图,而是直接将图保存到硬盘,主要的一个设置就是 matplotlib.use('agg') 注明: 其实不设置 matplotl ...
- JS禁止用F5键
//禁止用F5键 function document.onkeydown() { if ( event.keyCode==116) { event.keyCode = 0; event.cancelB ...
- opencv-learnopencv-Facial Landmark Detection
re: 1.facial-landmark-detection; https://www.learnopencv.com/facial-landmark-detection/ 2.landmark h ...
- 查看camera设备-linux
前言 本文介绍如何在linux平台查看是否有camera外设. 操作过程 1.打开shell,输入以下命令: ls /dev/video* 即可查看是否有camera外设: 2.如果确实连接了came ...