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 ...
随机推荐
- call、apply的应用
call方法: 语法:call([thisObj[,arg1[, arg2[, [,.argN]]]]]) 定义:调用一个对象的一个方法,以另一个对象替换当前对象. 说明: call 方法可以用来 ...
- 玩转X-CTR100 l STM32F4 l WS2812全彩LED灯
更多塔克创新资讯欢迎登陆[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ] WS2812B RGB全彩LED灯珠,只需通过一根信号线控制多个 ...
- DevExpress v17.2最新版帮助文档下载大全
DevExpress v17.2.4帮助文档下载列表大全来啦!包含.NET.VCL.HTML/JS系列所有帮助文档,提供CHM和PDF两个版本.除已停止更新的Silverlight.Windows 8 ...
- 太完美 TWM000极度精简版XP20130123终结美化版
TWM000极度精简版XP20130123终结美化版:蛋蛋20130123终结版为蓝本,虫子提供的美化包进行了美化.此版经测试完美在Z77主板开启AHCI安装,此为最终版之美化版!LiteXPMH.i ...
- HDU 3546
http://acm.hdu.edu.cn/showproblem.php?pid=3546 题意:10个寄存器初值为1,有加乘赋值运算,最多30w次运算,大数最多5000位,问最后10个寄存器的结果 ...
- DBWR进程
--查询dbwr进程号 select pname,spid from v$process where pname like 'DBW%'; PNAME SPID----- -------------- ...
- opencv图像读取-imread
前言 图像的读取和保存一定要注意imread函数的各个参数及其意义,尽量不要使用默认参数,否则就像数据格式出现错误(here)一样,很难查找错误原因的: re: 1.opencv图像的读取与保存; 完
- opencv实现遍历文件夹下所有文件
前言 最近需要将视频数据集中的每个视频进行分割,分割成等长的视频片段,前提是需要首先遍历数据集文件夹中的所有视频. 实现 1.了解opencv中的Directory类: 2.实现测试代码: 系统环境 ...
- stm32 内部温度传感器的配置
STM32的内部温度传感器和ADCx—IN16输入通道相连接.且温度传感器推荐采样时间为17.1us,支持的温度范围为:-40~125度,精度比较差,± 5℃左右. 计算温度值:T(℃) ={(V25 ...
- NSObject之二
前面一章我们整理了NSObject类,这一章我们来看看NSObject协议的内容. NSObject协议提供了一组方法作为Objective-C对象的基础.其实我们对照一个NSObject类和NSOb ...