HDU-1969 Pie
http://acm.hdu.edu.cn/showproblem.php?pid=1969
Pie
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3303 Accepted Submission(s): 1280
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.
#include<stdio.h>
#include<math.h>
#define pi acos(-1.0)
int n,f;
double a[10005];
int cmp(double v)
{
int i,sum=0;
for(i=0;i<n;i++)
sum+=int(a[i]/v);
if(sum>=f)
return 1;
else
return 0;
}
int main()
{
int t,i;
double size,right,left,mid,sum,temp;;
scanf("%d",&t);
while(t--)
{
sum=0;
scanf("%d%d",&n,&f);
f++;
for(i=0;i<n;i++)
{
scanf("%lf",&temp);
a[i]=pi*temp*temp;
sum+=a[i];
}
size=sum/f;
left=0;right=size;
while(right-left>1e-6)
{
mid=(right+left)/2;
if(cmp(mid))
left=mid;
else
right=mid;
}
printf("%.4lf\n",mid);
}
return 0;
}
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 ...
- hdoj 1969 Pie【二分】
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- HDU 1969 Pie(二分查找)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
- 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 (二分法)
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 ...
随机推荐
- CenOs安装中文输入法
http://jingyan.baidu.com/album/d8072ac4434666ec95cefda1.html?picindex=2 查看链接
- Context是什么,怎么用
一.Context是什么 开始学安卓的时候发现经常有context,但是都不知道为什么,什么时候需要它. 官方文档概述:关于应用程序环境的全局信息的接口.这是一个抽象类,它的实现是由安卓系统提供的.它 ...
- FragmentTransaction.addToBackStack无效的问题
FragmentTransaction.addToBackStack无效的问题: 如果当前的类继承的ActionBarActivity,则FragmentManager必须来自v4包,这样addToB ...
- Ubuntu12.04中安装ns-allinone-2.34
1.首先安装ns2所需的组件.库之类: $sudo apt-get update $sudo apt-get install build-essential $ tcl8.-dev tk8. tk8. ...
- 判断用户输入是否为int整型方法之一!
; string vv = this.textBox2.Text; if (int.TryParse(vv, out age)) { age = int.Parse(this.textBox2.Tex ...
- pip 的 Assert Error
在Ubuntu 14.04 中安装了Python之后,使用pip freeze,出现AssertError. 发现是pip版本太低,只有1.5.6 更新pip之后就OK了.
- shell命令:echo命令详解
功能说明:显示文字. 语 法:echo [-ne][字符串] / echo [--help][--version] 补充说明:echo会将输入的字符串送往标准输出.输出的字符串间以空白字符隔开, 并在 ...
- 简单学C——第七天
函数 函数是C语言重要的组成部分,你现在,或者以后(如果C没什么变化的话)所写的任何一个C语言程序都是由一个一个的函数组合在一起的,当然,现在或许你只会在主函数 main中写一个小程序,那么在看了本篇 ...
- Maven入门详解以及Eclisp的集成
1.首先要安装Maven到操作系统上 Maven的下载页面:http://maven.apache.org/download.html Maven跟Tomcat很像,下载下来后直接解压在指定的目录就安 ...
- 应用Java(环境变量)
工作中,不一定非要设置Java环境变量 因为,IDE自身环境的设置,代替了系统环境变量 环境变量 系统的环境变量,相当于软件工作的环境.工作中,经常需要设置以下变量: Path ClassPath 自 ...