hdu 1969 Pie (二分法)
Pie
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3133 Accepted Submission(s): 1217
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.
---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.
3 3
4 3 3
1 24
5
10 5
1 4 2 3 4 5 6 5 4 2
3.1416
50.2655
//31MS 328K 744 B C++
/* 题意:
开始表示看不懂,后来才知道是给出n块pie,和f+1个人,要求没个人只能拿一块,
可以是完整的一块也可以是不完整的一块。不一定要用上全部的pie。 二分法:
奇葩的题...
假设 x 为每个人在限制条件下能得到的最大的体积的pie,有: s[1]/x+s[2]/x+...+s[n]/x=f+1 //s[i]为第i块pie体积 然后再使用二分法求x,其中low=0,up=max{s[1],s[2],...,s[n]} */
#include<stdio.h>
#include<math.h>
#define eps 1e-7
//#define pi 3.14159265358979323846
#define pi acos(-1.0)
int main(void)
{
int t,n,f;
double s[],r;
scanf("%d",&t);
while(t--)
{
double up=,low=;
scanf("%d%d",&n,&f);
f+=;
for(int i=;i<n;i++){
scanf("%lf",&r);
s[i]=pi*r*r;
if(s[i]>up) up=s[i];
}
double mid=(up+low)/;
while(up-low>eps){
int cnt=;
for(int i=;i<n;i++)
cnt+=(int)(s[i]/mid);
if(cnt>=f) low=mid;
else up=mid;
mid=(up+low)/;
}
printf("%.4lf\n",mid); }
return ;
}
hdu 1969 Pie (二分法)的更多相关文章
- hdu 1969 Pie(二分查找)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1969 Pie Time Limit: 5000/1000 MS (Java/Others) Me ...
- HDU 1969 Pie(二分法)
My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N ...
- HDU 1969 Pie(二分查找)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
- HDU 1969(二分法)
My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N ...
- HDU 1969 Pie(二分搜索)
题目链接 Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pi ...
- HDU 1969 Pie(二分,注意精度)
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- HDU 1969 Pie【二分】
[分析] “虽然不是求什么最大的最小值(或者反过来)什么的……但还是可以用二分的,因为之前就做过一道小数型二分题(下面等会讲) 考虑二分面积,下界L=0,上界R=∑ni=1nπ∗ri2.对于一个中值x ...
- 题解报告:hdu 1969 Pie(二分)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
- hdu 1969 pie 卡精度的二分
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
随机推荐
- 短信状态监听 - iOS
当使用 App 时若短信介入需要对当前状态进行监听操作,根据不同的状态实行相关的需求操作,废话不多说步骤如下. 首先,常规操作先引用对应的头文件,来为后续功能铺路. #import <Messa ...
- Maven学习总结(10)
本文通过一个例子来介绍利用maven来构建一个多模块的jave项目.开发工具:intellij idea. 一.项目结构 multi-module-project是主工程,里面包含两个模块(Modul ...
- 【赛时总结】 ◇赛时·III◇ AtCoder ABC-099
◆赛时·III◆ ABC-099 ■唠叨■ 不要问我为什么先给ABC-100写了博客再写的ABC-099-- 莫名觉得这次比赛特别简单--虽然我并没有参加比赛,只是之后再补做的.QwQ ■试题& ...
- 实例:关于ALV控件可编辑的整理
使ALV控件中的内容可编辑 这应该是一个非常有用的功能,这样我们便可以用它来代替table control来编出一些有这现成功能的界面来.实际上,让alv中的内容可以被编辑与alv的事件无关.但是经常 ...
- java使用apache-poi生成excel表格
public static void main(String[] args) throws IOException { // TODO Auto-generated method stub //创建一 ...
- ES6笔记03-Set和Map数据结构
ES6提供了新的数据结构Set.它类似于数组,但是成员的值都是唯一的,没有重复的值.Set本身是一个构造函数,用来生成Set数据结构. var s = new Set(); [2, 3, 5, 4, ...
- linux系统的启动过程简要分析
接触linux系统运维已经好几年了,常常被问到linux系统启动流程问题,刚好今天有空来梳理下这个过程:一般来说,所有的操作系统的启动流程基本就是: 总的来说,linux系统启动流程可以简单总结为以下 ...
- python3 练习题100例 (十六)鸡尾酒疗法
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'Fan Lijun' n = input('请输入一个大于1,小于等于20的整 ...
- Python学习笔记:logging(日志处理)
在一个软件中,日志是可以说必不可少的一个组成部分,通常会在定位客户问题或者记录软件使用情况等场景中会用到.logging模板块是Python的一个内置标准库,用于实现对日志的控制输出,对于平常的日志输 ...
- Skyscrapers Covered in Solar Pancels【太阳能电池板覆盖的摩天大楼】
Skyscrapers Covered in Solar Panels An office tower on Miller Stree in Manchester is completely cove ...