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 sev-
eral 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
r
i
with 1
r
i
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
.做过啊 二分半径
  1. #include <set>
  2. #include <map>
  3. #include <queue>
  4. #include <deque>
  5. #include <cstdio>
  6. #include <string>
  7. #include <vector>
  8. #include <math.h>
  9. #include <time.h>
  10. #include <utility>
  11. #include <cstdlib>
  12. #include <sstream>
  13. #include <cstring>
  14. #include <stdio.h>
  15. #include <iostream>
  16. #include <algorithm>
  17. using namespace std;
  18. const double PI=3.141592653589793;
  19. int T;
  20. double a[];
  21. double l,r,n,f;
  22. bool C(double val)
  23. {
  24. int temp=;
  25. for(int i=;i<=n;i++)
  26. {
  27. temp+=a[i]/val;
  28. }
  29. if(temp>=f)return true;
  30. else return false;
  31. }
  32. int main()
  33. {
  34. cin>>T;
  35. while(T--)
  36. {
  37. cin>>n>>f;
  38. memset(a,,sizeof(a));
  39. for(int i=;i<=n;i++)
  40. {
  41. cin>>a[i];
  42. a[i]=a[i]*a[i]*PI;
  43. r=max(a[i],r);
  44. }
  45. r++;
  46. l=;
  47. f++;
  48. double mid=;
  49. while(r-l>0.000001)
  50. {
  51. mid=(l+r)/;
  52. if(C(mid))l=mid;
  53. else r=mid;
  54. }
  55. if(C(r))printf("%.4lf\n",r);
  56. else printf("%.4lf\n",mid);
  57. }
  58. return ;
  59. }

100722C的更多相关文章

随机推荐

  1. AC日记——求10000以内n的阶乘 openjudge 1.6 14

    14:求10000以内n的阶乘 总时间限制:  5000ms 内存限制:  655360kB 描述 求10000以内n的阶乘. 输入 只有一行输入,整数n(0<=n<=10000). 输出 ...

  2. KSFramework常见问题:Excel如何进行SVN协作、差异比较?

    Excel如何进行SVN协作.差异比较? 嗯,这是一个令人困惑的问题.游戏开发.程序开发时,使用Excel可以添加文档.注释.图标.批注等等各种辅助信息: 但是Excel是非纯文本格式,在使用SVN. ...

  3. Oracle 游标使用全解

    -- 声明游标:CURSOR cursor_name IS select_statement --For 循环游标 --(1)定义游标 --(2)定义游标变量 --(3)使用for循环来使用这个游标 ...

  4. 蓝灯github地址

    https://github.com/getlantern/lantern/ 闪电联盟蓝灯: http://bbs.sdbeta.com/read-htm-tid-556664.html

  5. mysql中判断记录是否存在方法比较

    我这里总结了判断记录是否存在的常用方法: sql语句:select count(*) from tablename; 然后读取count(*)的值判断记录是否存在.对于这种方法性能上有些浪费,我们只是 ...

  6. Linux execve函数簇用法

    exec函数簇实现的功能都是用一个新程序替换原来的程序,替换的内容包括堆栈段,代码段,进程控制器PCD,但是原进程的PID保持不变 int execl(const char *path, const ...

  7. 阿里云安装LNMP以及更改网站文件和MySQL数据目录

    LNMP安装了哪些软件?安装目录在哪LNMP相关软件安装目录Nginx 目录: /usr/local/nginx/MySQL 目录 : /usr/local/mysql/MySQL数据库所在目录:/u ...

  8. Android -- ActivityLifeCycleCallbacks

    ActivityLifeCycleCallbacks Application通过此接口提供了一套回调方法,用于让开发者对Activity的生命周期事件进行集中处理. 为什么用ActivityLifec ...

  9. lecture5-对象识别与卷积神经网络

    Hinton第五课 突然不知道object recognition 该翻译成对象识别好,还是目标识别好,还是物体识别好,但是鉴于范围性,还是翻译成对象识别吧.这一课附带了两个论文<Convolu ...

  10. 基于Laravel+Swoole开发智能家居后端

    基于Laravel+Swoole开发智能家居后端 在上一篇<Laravel如何优雅的使用Swoole>中我已经大概谈到了Laravel结合Swoole的用法. 今天,我参与的智能家居项目基 ...