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. 记一次 node.js 的populate用法

    最近在学习node.js做一个简单的博客的网站,用的express框架和mongodb的数据库.之前没有接触过这个数据库,所有在一开始写的时候遇到了一些问题,如何初始化model类型,又如何实现简单的 ...

  2. 【Python学习笔记之二】浅谈Python的yield用法

    在上篇[Python学习笔记之一]Python关键字及其总结中我提到了yield,本篇文章我将会重点说明yield的用法 在介绍yield前有必要先说明下Python中的迭代器(iterator)和生 ...

  3. vue实例讲解之axios的使用

    本篇来讲解一下axios插件的使用,axios是用来做数据交互的插件. 这篇将基于vue实例讲解之vue-router的使用这个项目的源码进行拓展. axios的使用步骤: 1.安装axios npm ...

  4. QT的安装及环境配置

    QT的安装及环境配置 一.windows的下QT的安装及环境配置 (一)从框架安装程序中安装 步骤: 准备:下载QT库,下载指定版本的MINGW,QT IDE 1.下载QT安装文件如:qt-win-o ...

  5. 关于如何更好地使用Github的一些建议

    关于如何更好地使用Github的一些建议 原文(Github repository形式): https://github.com/Wasdns/github-example-repo 本文记录了我对于 ...

  6. 关于form表单或者Ajax向后台发送数据时,数据格式的探究

    最近在做一个资产管理系统项目,其中有一个部分是客户端向服务端发送采集到的数据的,服务端是Django写的,客户端需要用rrequests模块模拟发送请求 假设发送的数据是这样的: data = {'s ...

  7. 关于修改extmail附件大小限制的位置

    一.修改extmail的webmail.cf文件, SYS_MESSAGE_SIZE_LIMIT = 5242880 注意:以位为单位为5M字节. SYS_MESSAGE_SIZE_LIMIT = x ...

  8. Socket简单实现数据交互及上传

    声明:本文为原创,如需转载请说明出处:http://www.cnblogs.com/gudu1/p/7669175.html 首先为什么要写这个呢?因为在几个月之前我还使用Socket做一个小项目,而 ...

  9. Opencv怎么读入,显示,保存图像-OpenCV步步精深

    怎么读入图像呢? 我们用 img = cv2.imread('图像路径\原图像名称',0) 原图像名称要有后缀 .png , .jpg等等原图像带有的后缀. 这里我们着重说明一下图像路径,这个路径一定 ...

  10. H5新手快速入门 简单布局

    布局*{ margin: 0; padding: 0;}.quan{ width: 100%; height: 2000px; background: black url("../ima/b ...