Pie(二分POJ3122)
来源:互联网 发布:arcgis批处理python 编辑:程序博客网 时间:2024/04/28 14:55
Pie
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 12985 Accepted: 4490 Special Judge
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.
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
33 34 3 31 24510 51 4 2 3 4 5 6 5 4 2
Sample Output
25.13273.141650.2655
Source
Northwestern Europe 2006
敲了半天才发现自己理解错题意了QAQ
题意:作者要开一个生日party,他现在拥有n块高度都为1的圆柱形奶酪,已知每块奶酪的底面半径为r不等,作者邀请了f个朋友参加了他的party,他要把这些奶酪平均分给所有的朋友和他自己(f+1人),每个人分得奶酪的体积必须相等(这个值是确定的),形状就没有要求。现在要你求出所有人都能够得到的最大块奶酪的体积是多少?
敲了半天才发现自己理解错题意了QAQ
题意:作者要开一个生日party,他现在拥有n块高度都为1的圆柱形奶酪,已知每块奶酪的底面半径为r不等,作者邀请了f个朋友参加了他的party,他要把这些奶酪平均分给所有的朋友和他自己(f+1人),每个人分得奶酪的体积必须相等(这个值是确定的),形状就没有要求。现在要你求出所有人都能够得到的最大块奶酪的体积是多少?
#include <set>#include <map>#include <list>#include <stack>#include <cmath>#include <vector>#include <queue>#include <string>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace std;typedef long long LL;const double Pi = 3.1415926535897932;const double eps = 1e-5;int n,m;double Arr[11000];bool Judge(double s){ int ans=0; for(int i=1; i<=n; i++) { ans+=(int)(Arr[i]/s); if(ans>=m+1) { return true; } } return false;}int main(){ int T; double r; scanf("%d",&T); while(T--) { scanf("%d %d",&n,&m); double L=0,R=0; for(int i=1; i<=n; i++) { scanf("%lf",&r); Arr[i]=r*r*Pi; R+=Arr[i]; } double ans=0; while(R-L>eps) { double mid=(L+R)/2; if(Judge(mid)) { ans=mid; L=mid; } else { R=mid; } } printf("%.4f\n",ans); } return 0;}
0 0
- POJ3122--Pie--二分
- poj3122 Pie(二分查找)
- Pie(二分POJ3122)
- POJ3122 Pie 二分查找
- poj3122 pie 二分
- POJ3122 Pie(二分)
- #POJ3122#Pie (二分)
- poj3122 Pie 二分
- POJ3122 Pie(二分)
- POJ3122 Pie(二分+贪心)
- 【二分答案】【POJ3122】【Northwestern Europe 2006】Pie
- poj3122--Pie(二分的精度问题)
- poj3122——Pie(二分+贪心)
- [poj3122]pie——简单二分
- POJ3122 pie
- poj3122 Pie
- Poj3122 Pie
- POJ3122-Pie
- SCST在SAN网络环境中的应用
- Java关键字之finalize
- 【Material Design视觉设计语言】应用样式设计
- 国内从事红外热成像的公司
- HDU 2502 月之数
- Pie(二分POJ3122)
- Android Service学习之AIDL, Parcelable和远程服务
- WPARAM和LPARAM的含义
- 【MaterialDesign】TabLayout,CollapsingToolbarLayout,AppBarLayout,CoordinatorLayout
- Spring MVC 原理详解
- jQuery 表单对象属性过滤现则器
- img src为空时请求服务器
- 图像处理职位面试题(图像处理+c++)
- KMP算法