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 ...
随机推荐
- Delphi操作Excel(Use Oel)
Use ComObj: procedure TorderMore1.BitBtn2Click(Sender: TObject);var xlsFile:WideString; var ExcelA ...
- 2基本类型数组和枚举类型——重拾Java
2.1 标识符和关键字 2.1.1标识符 标识符:用来标志类名.变量名.方法名.类型名.数组名.文件名的有效字符序列称为标识符.简单地说,标识符就是一个名字. Java关于标识符的语法规则 标识符由字 ...
- ASP.NET MVC 项目文件夹结构
首先,打开Visual Studio, 新建一个demo 项目的solution,选择 Blank Soution. 第二步,创建文件夹,按自己的需求创建.在这个Demo 中,我将创建4个文件夹. P ...
- Linux Tomcat重新启动
在Linux系统下,重启Tomcat使用命令操作的! 首先,进入Tomcat下的bin目录 cd /usr/local/tomcat/bin 使用Tomcat关闭命令 ./shutdown.sh 查看 ...
- jquery 不选择第一个
参考 https://zhidao.baidu.com/question/174343639.html th:not(':first')
- OC 线程操作2 - NSThread
方法1 :直接创建 alloc init - (void)createNSThread111{ /* 参数1: (nonnull id) 目标对象 self 参数2:(nonnull SEL) ...
- swift OC混编工程,xcode断点调试,控制台左侧只有变量名称不显示值,右侧输入po命令,打印除一堆提示
断点调试 (lldb) po 变量名warning: Swift error in module 项目名.Debug info from this module will be unavailable ...
- VideoView的全屏问题
package com.bi.standardcompuse.app.widgets; import android.content.Context;import android.util.Attri ...
- ADF学习实用网站
ADF中所有组件工功能例子 http://jdevadf.oracle.com/adf-richclient-demo/faces/components/dialog.jspx;jsessionid= ...
- Windows下Python IDLE设置
Windows下安装Python 2.7.5,发现IDLE是个不错的IDE,可以编辑.运行, 希望与.py文件关联起来,作为编辑器使用,经过尝试,找到了一个方法. 打开注册表,找到\KEY_CLA ...