Pie
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.
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.
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).
6 5 4 2
#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的更多相关文章
- [No0000A2]“原始印欧语”(PIE)听起来是什么样子?
"Faux Amis"节目中经常提到"原始印欧语"(PIE)——"Proto-Indo-European". 我们说过,英语,法语中的&qu ...
- poj3311 Hie with the Pie (状态压缩dp,旅行商)
Hie with the Pie Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 3160 Accepted: 1613 ...
- pygame 练习之 PIE game (以及简单图形训练)
简单的大饼游戏,掌握pygame中直线以及圆弧的画法,以及对输入的响应. import math import pygame, sys from pygame.locals import * pyga ...
- Pizza Pie Charts – 基于 Snap SVG 框架的响应式饼图
Pizza Pie Charts 是一个基于 Adobe 的 Snap SVG 框架的响应式饼图插件.它着重于集成 HTML 标记和 CSS,而不是 JavaScript 对象,当然Pizza Pie ...
- 【poj3122】 Pie
http://poj.org/problem?id=3122 (题目链接) 题意 给出N个pie的半径和F个friend,每个friend得到的pie必须一样,求每个人能得到的pie的最大大小. so ...
- tcpdump for android L 5.x with pie support
由于使用了NDK编译的可执行文件在应用中调用,在4.4及之前的版本上一直没出问题. 最近由于要测试在Android L上的运行情况发现,当运行该可执行文件时,报如下错误: error: only po ...
- 分馅饼 Pie
Pie 链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/C 题目: Problem Description ...
- Pie(二分POJ3122)
Pie Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12985 Accepted: 4490 Special Ju ...
- poj3122 pie
方法:二分. 题目意思:要过生日了,我请大家吃pie,然后人数一共是f+1(我自己).每个人的pie不能是拼接的,而且每个人的面积是一样的,这样就用二分枚举. 范围是0-最大的那块pie. 然后用每一 ...
- PIC和PIE
PIC指的是位置无关代码,用于生成位置无关的共享库,所谓位置无关,指的是共享库的代码断是只读的,存放在代码段,多个进程可同时公用这份代码段而不需要拷贝副本.库中的变量(全局变量和静态变量)通过GOT表 ...
随机推荐
- 中位数的和_KEY
中位数的和 (number.pas/c/cpp) [题目描述] flower 有 N-1 个朋友,他们要一起玩一个游戏:首先确定三个非负整数 a,b,c,然后每个人依次在纸上写一个数,设第 i 个人写 ...
- 化繁为简 经典的汉诺塔递归问题 in Java
问题描述 在世界中心贝拿勒斯(在印度北部)的圣庙里,一块黄铜板上插着三根宝石针.印度教的主神梵天在创造世界的时候,在其中一根针上从下到上地穿好了由大到小的64片金片,这就是所谓的汉诺塔.不论白天黑 ...
- Dubbo分布式服务子系统的划分
一.划分子系统的策略 按照系统的业务模块的独立性划分 二.划分时服务子系统的数量的控制 过多:可能划分过细,破坏业务子系统的独立性,部署维护工作量大,独立进程占用内存多 过少:没能很好的解耦,开发维护 ...
- Online Bayesian Probit Regression介绍之Factor Graph
下面就开始讲讲概率图中的Factor Graph.概率图博大精深,非我等鼠辈能够完全掌握,我只是通过研究一些通用的模型,对概率图了解了一点皮毛.其实我只是从概率这头神兽身上盲人摸象地抓掉几根毛,我打算 ...
- 我的第一个python web开发框架(5)——开发前准备工作(了解编码前需要知道的一些常识)
中午吃饭时间到了,小白赶紧向老菜坐的位置走过去. 小白:老大,中午请你吃饭. 老菜:哈哈...又遇到问题了吧,这次得狠狠宰你一顿才行. 小白:行行行,只要您赏脸,米饭任吃,嘻嘻,我们边走边聊. ... ...
- JavaScript链式调用
1.什么是链式调用? 这个很容易理解,例如 $('text').setStyle('color', 'red').show(); 一般的函数调用和链式调用的区别:链式调用完方法后,return thi ...
- 【源码】canal和otter的高可靠性分析
一般来说,我们对于数据库最主要的要求就是:数据不丢.不管是主从复制,还是使用类似otter+canal这样的数据库同步方案,我们最基本的需求是,在数据不丢失的前提下,尽可能的保证系统的高可用,也就是在 ...
- 笨鸟先飞之ASP.NET MVC系列之过滤器(05结果过滤器)
概念介绍 结果过滤器看名字就知道这个过滤器是针对方法所产生结果的,结果过滤器,主要在我们的动作方法结果返回前后执行. 如果我们需要创建结果过滤器需要实现IResultFilter接口. namespa ...
- 如何让vim像IDE一样一键放大缩小字号?
原创,转载请注明出处 在其他IDE中,比如codeblocks,按住ctrl,然后滑动鼠标滚轮就可以实现字体的放大缩小. 在强大的vim中code怎么能缺少这种功能?! 在vim插件库中查询一番,发现 ...
- JAVA提高七:类加载器
今天我们学习类加载器,关于类加载器其实和JVM有很大关系,在这里这篇文章只是简单的介绍下类加载器,后面学习到JVM的时候还会详细讲到类加载器,本文分为下面几个小节讲解: 一.认识类加载器 1.什么是类 ...