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表 ...
随机推荐
- oracle sql 树操作
语法:select-start with-connect by-prior 主要有两点 1)prior放在子节点端,则表示扫描树是以start with指定的节点作为根节点从上往下扫描.可能对应一个或 ...
- LINUX通过PXE自动部署系统
原理介绍 TFTP(Trivial File Transfer Protocol,简单文件传输协议)是TCP/IP 协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂.开销不大的 ...
- Ubuntu升级出现/boot空间不足解决
经常升级Linux内核,导致更新时警告/boot分区空间不足.这是以为多次升级内核后,导致内核版本太多,清理一下没用的内核文件就行了.命令如下: zht@zht-Ubuntu:~$ dpkg -l ' ...
- 18.Llinux-触摸屏驱动(详解)
本节的触摸屏驱动也是使用之前的输入子系统 1.先来回忆之前第12节分析的输入子系统 其中输入子系统层次如下图所示, 其中事件处理层的函数都是通过input_register_handler()函数注册 ...
- Java伪代码描述《大道至简》第一章
第一节 Begin //原始需求 惩山北之塞,出入之迂 //项目沟通的基本方式 聚室而谋曰 //项目目标 毕力平险,指通豫南,达于汉阴 //技术方案 扣石垦壤,箕畚运于渤海之尾 //技术人员和工程管理 ...
- Distribute Candies
Given an integer array with even length, where different numbers in this array represent different k ...
- spring 内部工作机制(一)
Spring内部机制的内容较多,所以打算多分几个阶段来写. 本章仅探索Spring容器启动做了哪些事: 前言: 都说Spring容器就像一台构造精妙的机器,此话一点不假,我们通过配置文件向机器传达控制 ...
- TargetType Mismatch
TargetType Mismatch 环境:windowsphone 8,silerlight toolkit, 页面报TargeType Mismatch错误或者 length 0,是因为Syst ...
- Android签名机制---签名过程
大神文章:http://blog.csdn.net/jiangwei0910410003/article/details/50402000 一.知识点 1.数据摘要(数据指纹).签名文件,证书文件 2 ...
- jdk8与jdk9的共存
以前安装JDK,需要手动配置环境变量.JDK8多了自动配置环境变量,所以可以不用手动配置. 如果我已经装了JDK8,还想再装一个JDK9,安装完,自动配置的环境变量会指向JDK9版本. 解决方法 删除 ...