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 ...
随机推荐
- gitignore中常见需要被无视的文件
gitignore中常见的需要被忽略的文件:例如各个系统.一些软件会自动生成的文件,主要适用于web项目. 复制后,保存进.gitignore文件中即可. # Project node_modules ...
- 玩转X-CTR100 l STM32F4 l UCOS-III移植
我造轮子,你造车,创客一起造起来!塔克创新资讯[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ] 概述 前后台系统 简单的小型系统设计一般是基于前后台 ...
- php session和cookie知识
- Appium 使用小结
前言: Appium 是通过模拟用户操作进行自动化操控手机端第三方库.通常使用场景多用于回归测试.在产品教成熟,页面改动较少后,通过ui自动化进行回归操作测试. Appium 本身使用很简单,java ...
- Home Kit框架简介
重要:本文是针对开发过程中使用的API或者技术的初步文档.苹果提供该文档旨在为开发者使用该技术和苹果产品上的编程接口提供帮助.这些信息可能会发生变化,依据该文档开发的软件应该使用最新的操作系统软件和最 ...
- [Algorithm] A nonrecursive algorithm for enumerating all permutations of the numbers {1,2,...,n}
def permutationN(n): a=[None]*n for i in range(n): a[i]=i+1 sum=1 for j in range(n): sum*=(j+1) i=0 ...
- 教你正确进入DFU及恢复模式 无敌重刷模式
苹果分为两种恢复模式,一种叫做DFU模式,另一种是恢复模式.DFU的全称是Development FirmwareUpgrade,实际意思就是iPhone固件的强制升降级模式.而恢复模式则是屏幕上会显 ...
- URAL - 1003:Parity (带权并查集&2-sat)
Now and then you play the following game with your friend. Your friend writes down a sequence consis ...
- Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined
遇到问题: Android NDK: jni/Android.mk: Cannot find module with tag 'XXXXXXXXX' in import path Android ND ...
- Complete the Word
ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring ...