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

My birthday is coming up and traditionally I'm serving 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.

Input

One line with a positive integer: the number of test 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.

Output

For each test case, output one line with the largest 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).

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) 收藏的更多相关文章

  1. 团体程序设计天梯赛L1-019 谁先倒 2017-03-22 17:35 33人阅读 评论(0) 收藏

    L1-019. 谁先倒 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 划拳是古老中国酒文化的一个有趣的组成部分.酒桌上两人划拳 ...

  2. Hdu1342 Lotto 2017-01-18 17:12 44人阅读 评论(0) 收藏

    Lotto Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submiss ...

  3. Hdu1401 Solitaire 2017-01-18 17:21 33人阅读 评论(0) 收藏

    Solitaire Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Sub ...

  4. POJ1789 Truck History 2017-04-13 12:02 33人阅读 评论(0) 收藏

    Truck History Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 27335   Accepted: 10634 D ...

  5. 百度地图-省市县联动加载地图 分类: Demo JavaScript 2015-04-26 13:08 530人阅读 评论(0) 收藏

    在平常项目中,我们会遇到这样的业务场景: 客户希望把自己的门店绘制在百度地图上,通过省.市.区的选择,然后加载不同区域下的店铺位置. 先看看效果图吧: 实现思路: 第一步:整理行政区域表: 要实现通过 ...

  6. Eclipse 快捷键大全 分类: C_OHTERS 2014-06-01 13:05 332人阅读 评论(0) 收藏

      精选常用: 1.  ctrl+shift+r:打开资源 这可能是所有快捷键组合中最省时间的了.这组快捷键可以让你打开你的工作区中任何一个文件,而你只需要按下文件名或mask名中的前几个字母,比如a ...

  7. MS SQLServer 批量附加数据库 分类: SQL Server 数据库 2015-07-13 11:12 30人阅读 评论(0) 收藏

    ************************************************************ * 标题:MS SQLServer 批量附加数据库 * 说明:请根据下面的注释 ...

  8. 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 ...

  9. Power Network 分类: POJ 2015-07-29 13:55 3人阅读 评论(0) 收藏

    Power Network Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 24867 Accepted: 12958 Descr ...

随机推荐

  1. 显示AVI文件的桢数

    procedure TForm1.Button1Click(Sender: TObject);begin  MediaPlayer1.TimeFormat := tfFrames;  ShowMess ...

  2. select 中添加option的注意

    在平时写JS中经常要给Select添加option,如果我们把option中的数据用一个字符串来表示: eg: var strOption='<option>1</option> ...

  3. Moment-JavaScript 日期处理类库

    来源:http://momentjs.cn/ 日期格式化 moment().format('MMMM Do YYYY, h:mm:ss a'); // 二月 22日 2017, 4:04:26 下午 ...

  4. hadoop 官方配置文件解析

    比如我的版本是2.8.4 官网文档是: http://hadoop.apache.org/docs/r2.8.4/ 基本配置文件:包括一般的端口 hdfs-default.xml dfs.nameno ...

  5. 关于HSTS安全协议的全面详细解析

    HTTP 严格传输安全(HSTS)是一种安全功能,web 服务器通过它来告诉浏览器仅用 HTTPS 来与之通讯,而不是使用 HTTP.HSTS是网站从HTTP到HTTPS中网站性能及安全优化非常重要的 ...

  6. python3 django连接mysql,同步表结构

    第一步:安装PyMySQ代替MySQLdb pip3 install PyMySQL 然后在工程目录的__init__.py中填写下面两句话   import pymysql pymysql.inst ...

  7. padding-top和margin-top的区别

    学习前端知识,对我们查找页面元素很有帮助,而且自己在原公司时,有参与一个QA系统,自己去设计了这个产品,出了原型图,同时设计了几个页面,希望通过做这个产品提高自己的技术,可是因为离职,所以计划搁浅了, ...

  8. python OSError: [Errno 22] Invalid argument: 'D:\\crawle\x01.html1'

    import urllib.request file = urllib.request.open("http://www.baidu.com") data = file.read( ...

  9. 各种语言使用HTTP Request

    1. JAVA String requestContent = "{"id":"1","sort":"des" ...

  10. hadoop应用场景总结

    原文地址 我个人接触hadoop仅仅不到一年,因为是业余时间学习,故进度较慢,看过好多视频,买过好多书,学过基本知识,搭建过伪分布式集群,有过简单的教程式开发,恰逢毕业季,面试过相关岗位,自认为路还很 ...