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
题意:小明过生日朋友来做客,小明用披萨招待他们,有大小不一样的很多披萨,一个朋友分一块,这一块必须是整的,不能一块块的凑起来,并且小明也想吃,每个人必须相同;
解题思路:从最大的饼里求出来最大能分得饼m,然后再1~m之间用二分求最大分饼数,二分的题真是***(脏话自动屏蔽)圆周率需要3.14159265358979323846!!!!
代码(g++)
#include

#include

#include

#define maxn 10010

using namespace std;

double pie[maxn];

double maxn_pie(int n,int f,double pie[])//理想中的能分到的最大披萨

{

    double
sum=0;

    for(int
i=0;i

       
sum+=pie[i];

    return
sum/(f+1);//总共f个朋友加我

}



int main()

{

   
//freopen("in.txt", "r", stdin);

    int
t,n,f;

    double
m_pie=-1,p=0,p1,p2;

   
scanf("%d",&t);

    for(int
i=0;i

    {

       
memset(pie,0,sizeof(pie));

       
m_pie=-1;

       
scanf("%d%d",&n,&f);

       
for(int j=0;j

       
{

           
scanf("%lf",&pie[j]);

           
//注意!!!!pi的精度最少得是我写的这么多,要不后果自负!!!

           
pie[j]=pie[j]*pie[j]*3.14159265358979323846;//每个饼的面积(因为高都是1,所以分面积

//就行了)

           
if(pie[j]>m_pie)

               
m_pie=pie[j];//把最大面积的披萨求出来

       
}

       
//printf("最大的披萨是%.4lf\n",m_pie);

       
p1=0;

       
p2=m_pie;

       
while(p2-p1>1e-6)//开始在最大的披萨中二分来求最大部分披萨了

       
{

           
p=(p1+p2)/2;

           
//printf("p=%.4lf\n",p);

           
int ans=0;

           
for(int i=0;i

               
ans+=(int)(pie[i]/p);//剩下的不要了

           
if(ans>=f+1)

               
p1=p;

           
else if(ans

               
p2=p;

       
}

       
printf("%.4f\n",p1);

    }

}

Pie的更多相关文章

  1. [No0000A2]“原始印欧语”(PIE)听起来是什么样子?

    "Faux Amis"节目中经常提到"原始印欧语"(PIE)——"Proto-Indo-European". 我们说过,英语,法语中的&qu ...

  2. poj3311 Hie with the Pie (状态压缩dp,旅行商)

    Hie with the Pie Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3160   Accepted: 1613 ...

  3. pygame 练习之 PIE game (以及简单图形训练)

    简单的大饼游戏,掌握pygame中直线以及圆弧的画法,以及对输入的响应. import math import pygame, sys from pygame.locals import * pyga ...

  4. Pizza Pie Charts – 基于 Snap SVG 框架的响应式饼图

    Pizza Pie Charts 是一个基于 Adobe 的 Snap SVG 框架的响应式饼图插件.它着重于集成 HTML 标记和 CSS,而不是 JavaScript 对象,当然Pizza Pie ...

  5. 【poj3122】 Pie

    http://poj.org/problem?id=3122 (题目链接) 题意 给出N个pie的半径和F个friend,每个friend得到的pie必须一样,求每个人能得到的pie的最大大小. so ...

  6. tcpdump for android L 5.x with pie support

    由于使用了NDK编译的可执行文件在应用中调用,在4.4及之前的版本上一直没出问题. 最近由于要测试在Android L上的运行情况发现,当运行该可执行文件时,报如下错误: error: only po ...

  7. 分馅饼 Pie

    Pie 链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/C 题目: Problem Description ...

  8. Pie(二分POJ3122)

    Pie Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12985   Accepted: 4490   Special Ju ...

  9. poj3122 pie

    方法:二分. 题目意思:要过生日了,我请大家吃pie,然后人数一共是f+1(我自己).每个人的pie不能是拼接的,而且每个人的面积是一样的,这样就用二分枚举. 范围是0-最大的那块pie. 然后用每一 ...

  10. PIC和PIE

    PIC指的是位置无关代码,用于生成位置无关的共享库,所谓位置无关,指的是共享库的代码断是只读的,存放在代码段,多个进程可同时公用这份代码段而不需要拷贝副本.库中的变量(全局变量和静态变量)通过GOT表 ...

随机推荐

  1. Spring 学习——基于Spring WebSocket 和STOMP实现简单的聊天功能

    本篇主要讲解如何使用Spring websocket 和STOMP搭建一个简单的聊天功能项目,里面使用到的技术,如websocket和STOMP等会简单介绍,不会太深,如果对相关介绍不是很了解的,请自 ...

  2. DLL生成与使用的全过程

    由dll导出的lib文件: 包含了每一个dll导出函数的符号名和可选择的标识号以及dll文件名,不含有实际的代码(这里的lib文件和静态库是不一样的),其中的导出导入函数都 是跳转指令,直接跳转到DL ...

  3. vue学习之vue基本功能初探

    vue学习之vue基本功能初探: 采用简洁的模板语法将声明式的将数据渲染进 DOM: <div id="app"> {{ message }} </div> ...

  4. Java历程-初学篇 Day04选择结构(1)

    一,if 1,单分支 if(条件){ } 示例: 2,双分支 if(条件){ }else{ } 示例: 3,多重if if(条件){ }else if(条件){ }else{ } 示例: 4,嵌套if ...

  5. 手把手教你用npm发布一个包,详细教程

    我们已经实现了路由的自动化构建,但是我们可以看到,一大串代码怼在里面.当然你也可以说,把它封装在一个JS文件里面,然后使用require('./autoRoute.js')给引入进来,那也行.但是,为 ...

  6. Cmder 软件中修改λ符号方法

    以前的版本 网上都有,我就不介绍了,  只介绍现在的 1. 打开Cmder软件安装位置 2. 打开vendor文件夹 profile.ps1文件 3. 找到第77行  Write-Host " ...

  7. jsp web JavaBean MVC 架构 EL表达式 EL函数 JSTL

     一.JavaBean概念(非常重要) 1.JavaBean就是遵循一定书写规范的Java类型(开发中:封装数据) a.必须有默认的构造方法,类必须是public的   public class  ...

  8. easyUI tree点击文字展开节点

    easyUI默认展开树的时候,点击节点前边的黑色小三角 ,这样操作存在不人性化的地方,在实际使用中由于老旧电脑的存在和大龄使用者的眼花经常点不准:因此要实现点击节点名称展开的方式,其实就是在展开事件上 ...

  9. doubi -- 初创

    doubi -- 初创 [背景分析] 一直在苦苦探寻人生的价值和意义.在这"二八"年华,对IT工作有点厌倦了.每天都是无休止地问题定位,需求会议.碎片化的时间写出来的代码都是无比的 ...

  10. Re-Order Buffer

    Re-order Buffer(ROB)是处理器中非常重要的一个模块,它位于renamer与scheduler(RS)之间,并且也是execution unit(EU)的出口.ROB作为指令处理的后端 ...