Pie--hdu1969(二分法)
Pie
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6158 Accepted Submission(s):
2343
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.
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.
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).
- #include<cstdio>
- #include<cstring>
- #include<algorithm>
- #include<cmath>
- #define PI acos(-1.0)//PI的精度最好大点
- using namespace std;
- double L[] , man;
- int n,k,i;
- bool F(double x)
- {
- int sum=;
- for(i=;i<n;i++)
- sum+=(int)(L[i]/x);//sum的作用是记录当要求的面积为x时,最多能分多少整块
- return sum>=(k+);//如果能分的比要求的多就返回真
- }
- void qw()
- {
- double l=,r=man,mid;
- while(r-l>1e-)//二分法
- {
- mid=(l+r)/;
- if(F(mid))
- l=mid;
- else
- r=mid;
- }
- printf("%.4lf\n",r);
- }
- int main()
- {
- int N,T;
- scanf("%d",&N);
- while(N--)
- {
- scanf("%d%d",&n,&k);
- man =;
- for(i=;i<n;i++){
- scanf("%d",&T);
- L[i] = PI*T*T;
- if(man < L[i]) man = L[i];//找出最大的蛋糕面积
- }
- qw();
- }
- return ;
- }
Pie--hdu1969(二分法)的更多相关文章
- 分派pie(二分法)
2.问题描述 我的生日要到了!根据习俗,我需要将一些派分给大家.我有N个不同口味.不同大小的派.有F个朋友会来参加我的派对,每个人会拿到一块派(必须一个派的一块,不能由几个派的小块拼成:可以是一整个派 ...
- HDU 1969 Pie(二分法)
My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N ...
- UVA 12097 LA 3635 Pie(二分法)
Pie My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a numbe ...
- UVALive 3635 Pie(二分法)
简单的二分法应用,循环1000次精度就满足要求了. #include<iostream> #include<cstdio> #include<cstdlib> #i ...
- hdu 1969 Pie (二分法)
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- 二分法经典习题——HDU1969
#include <iostream>#include <cmath>#include <iomanip>using namespace std; double p ...
- HDU1969:Pie(二分)
Pie Time Limit : 5000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submissio ...
- Hdu1969 Pie 2017-01-17 13:12 33人阅读 评论(0) 收藏
Pie Time Limit : 5000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submissio ...
- POJ 3122 pie (二分法)
Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have ...
- POJ-3122.Pie(二分法最大化平均值)
二分法的主题思路就是逐步逼近,所以这道题的思路自然一目了然,做题思路也是... 本题大意:题主过生日,它买了N块半径为R[ i ],高为1的圆柱形蛋糕,现在他要将这N块蛋糕等分给F + 1个人,为了好 ...
随机推荐
- spring3+hibernate3+(dbcp+oracle+拦截器事务配置)整合(一)
1.applicationContext-base.xml文件 <?xml version="1.0" encoding="UTF-8"?>< ...
- 对于C++中const & T operator= 的一点思考
一个正常的assignment操作符的声明是这样的. const elmentType & elmentType::operator=(const elmentType &rhs) 这 ...
- Compiler Principles 语法分析
语法分析的两种思维方式:1:自顶向下分析 :从语法树的根部推下来一直推到需要确认的终结符号串为止:就是为了找到一个符号串的最左推导 自顶向下分析,因为文法有些是以非终结符开头的另外文法中还可能含有右部 ...
- 二维码识别:Halcon与C++中多字节环境下的字节编码格式设置和转换
Halcon环境下可通过设置set_system(‘filename_encoding’, ‘utf8’),可以将二维码的识别结果解析出汉字. VS环境下则需要将utf8转换成gbk格式.代码如下: ...
- 在一个exe文件中查找指定内容,找到则返回起始位置, 否则返回0
//在一个exe文件中查找指定内容,找到则返回起始位置, 否则返回0//如果某字符串, 直接传入字符串进来//如果要查找16进制,则用如下格式传参进来: #$1A#$2A#$3A function F ...
- 锁机制与原子操作 <第四篇>
一.线程同步中的一些概念 1.1临界区(共享区)的概念 在多线程的环境中,可能需要共同使用一些公共资源,这些资源可能是变量,方法逻辑段等等,这些被多个线程共用的区域统称为临界区(共享区),临界区的资源 ...
- CircleImageView自定义圆形控件的使用
1.自定义圆形控件github地址: https://github.com/hdodenhof/CircleImageView 主要的类: package de.hdodenhof.circleima ...
- 学DSP(一):开始
DSP有digital signal process 和 digital signal processor 2个意思,数字信号处理和数字信号处理器,我这里就是学数字信号处理器了. 我为什么要学DSP, ...
- UESTC_秋实大哥掰手指 2015 UESTC Training for Dynamic Programming<Problem B>
B - 秋实大哥掰手指 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 2048/1024KB (Java/Others) Submit ...
- Python的if判断与while循环
1.if判断 Python 编程中 if 语句用于控制程序的执行,基本形式为: if 判断条件: 执行语句 else: 执行语句 Python中使用缩进代替c语言中的大括号,来告诉程序所执行的内容. ...