Hdu1969 Pie 2017-01-17 13:12 33人阅读 评论(0) 收藏
Pie
Time Limit : 5000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 67 Accepted Submission(s) : 34
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
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.
Input
---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.
Output
Sample Input
3
3 3
4 3 3
1 24
5
10 5
1 4 2 3 4 5 6 5 4 2
Sample Output
25.1327
3.1416
50.2655
题意:给出n个蛋糕的半径,还有m+1个人,每个人的馅饼必须是整块的,不能拼接,求最大的。
思路:因为不能拼接,所以直接在最大那块的面积与0之间二分求即可
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const double pi=acos(-1.0); int m,n;
double s[10005];
bool cmp(double a,double b)
{
return a>b;
} int fen(double a)
{
int cnt=0;
for(int i=0;i<m;i++)
{
cnt+=(int)(s[i]/a);
}
if(cnt<n)
return 1;
else
return 0;
} int main()
{
int o;
double p;
scanf("%d",&o);
while(o--)
{
scanf("%d%d",&m,&n);
n++;
for(int i=0;i<m;i++)
{
scanf("%lf",&p);
s[i]=pi*p*p;
}
sort(s,s+m,cmp);
if(n<m)
m=n;
double l=0;
double r=s[0];
double mid;
while(r-l>1e-6)
{
mid=(l+r)/2;
if(fen(mid))
r=mid;
else
l=mid;
}
printf("%.4f\n",mid); }
return 0;
}
Hdu1969 Pie 2017-01-17 13:12 33人阅读 评论(0) 收藏的更多相关文章
- 团体程序设计天梯赛L1-019 谁先倒 2017-03-22 17:35 33人阅读 评论(0) 收藏
L1-019. 谁先倒 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 划拳是古老中国酒文化的一个有趣的组成部分.酒桌上两人划拳 ...
- Hdu1342 Lotto 2017-01-18 17:12 44人阅读 评论(0) 收藏
Lotto Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submiss ...
- Hdu1401 Solitaire 2017-01-18 17:21 33人阅读 评论(0) 收藏
Solitaire Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Sub ...
- POJ1789 Truck History 2017-04-13 12:02 33人阅读 评论(0) 收藏
Truck History Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 27335 Accepted: 10634 D ...
- 百度地图-省市县联动加载地图 分类: Demo JavaScript 2015-04-26 13:08 530人阅读 评论(0) 收藏
在平常项目中,我们会遇到这样的业务场景: 客户希望把自己的门店绘制在百度地图上,通过省.市.区的选择,然后加载不同区域下的店铺位置. 先看看效果图吧: 实现思路: 第一步:整理行政区域表: 要实现通过 ...
- Eclipse 快捷键大全 分类: C_OHTERS 2014-06-01 13:05 332人阅读 评论(0) 收藏
精选常用: 1. ctrl+shift+r:打开资源 这可能是所有快捷键组合中最省时间的了.这组快捷键可以让你打开你的工作区中任何一个文件,而你只需要按下文件名或mask名中的前几个字母,比如a ...
- MS SQLServer 批量附加数据库 分类: SQL Server 数据库 2015-07-13 11:12 30人阅读 评论(0) 收藏
************************************************************ * 标题:MS SQLServer 批量附加数据库 * 说明:请根据下面的注释 ...
- hdu 1712, multiple-choice knapsack, 分类: hdoj 2015-07-18 13:25 152人阅读 评论(0) 收藏
reference: 6.4 knapsack in Algorithms(算法概论), Sanjoy Dasgupta University of California, San Diego Chr ...
- Power Network 分类: POJ 2015-07-29 13:55 3人阅读 评论(0) 收藏
Power Network Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 24867 Accepted: 12958 Descr ...
随机推荐
- Haskell语言学习笔记(64)Lens(4)
安装 lens-tutorial Control.Lens.Tutorial $ cabal install lens-tutorial Installed lens-tutorial-1.0.3 P ...
- 疯狂JAVA——第六章 面向对象(下)
6.1包装类 java为了照顾程序员的传统习惯,所以提供了八种基本数据类型.但也带来不方便,例如所有引用类型都继承自Object类,都可当做Object类型变量使用.但基本数据类型的变量就不可以.如果 ...
- Error: Cannot find a valid baseurl for repo: epel
修改一下/etc/yum.repos.d/epel.repo文件, enable=1改为enable=0
- alter 和 update的用法和区别
alter的增加和删除alter table xs_kc add xuefen number;alter table xs_kc drop column xuefen; 删除的时候必须使用column ...
- ubuntu下安装.deb包的安装方法
ubuntu16.04的软件中心应该是有bug,安装不了第三方.deb文件,我们只有使用dpkg -i 或者gdebi的方式安装,我使用的是后者,因为后者功能更加强大.要使用gdebi命令先要安装它: ...
- Python 中 (&,|)和(and,or)之间的区别
&,|)和(and,or)是两组比较相似的运算符,用在“与”/ “或”上,在用法上有些许区别. (&,|)和(and,or)是用来比较两组变量的,格式基本上是: a & ba ...
- python之字符串【str】
#Auther Bob#--*--conding:utf-8 --*-- #定义一个str的对象,有下面两种方法name = 'Bob abc'job = str('it')print(type(na ...
- C&C++内存布局
1. Memory Layout of a C Program http://codingfreak.blogspot.com/2012/03/memory-layout-of-c-program-p ...
- window.location.origin
当前页面的域名+端口号 var HTTP_REMOTE = (function () { var origin = window.location.origin; if (origin.match(/ ...
- c++11多线程学习笔记之二 mutex使用
// 1111111.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #include ...