POJ 3122-Pie(二分+精度)
题目地址: id=3122">POJ 3122
题意:给出n个pie的直径。有F+1个人,假设给每人分的大小同样(形状能够不同),每一个人能够分多少。要求是分出来的每一份必须出自同一个pi(既当pie大小为3。2,1,仅仅能分出两个大小为2的份,剩下两个要扔掉。)
思路:对每个人分的大小进行二分。
注意讲pi放在最后成。能够提高精度。
Ps:wa了5发。不知道错在哪,然后把输出的%lf改成%f就A了,并不知道为什么。。。sad
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
typedef long long LL;
const int inf=0x3f3f3f3f;
const double pi= acos(-1.0);
const double esp=1e-6;
const int maxn=10010;
double a[maxn];
int main()
{
int T,n,F;
scanf("%d",&T);
while(T--){
double low=0,high=0;
scanf("%d %d",&n,&F);
F+=1;
for(int i=0;i<n;i++){
scanf("%lf",&a[i]);
a[i]=a[i]*a[i];
high=max(high,a[i]);
} double mid;
int cnt;
while(high-low>esp){
cnt=0;
mid=(low+high)/2;
for(int i=0;i<n;i++)
cnt+=(int)(a[i]/mid);
if(cnt>=F){
low=mid;
}
else
high=mid;
}
printf("%.4f\n",mid*pi); }
return 0;
}
POJ 3122-Pie(二分+精度)的更多相关文章
- POJ 3122 Pie 二分枚举
题目:http://poj.org/problem?id=3122 这个题就好多了,没有恶心的精度问题,所以1A了.. #include <stdio.h> #include <ma ...
- POJ 3122 Pie 二分答案
题意:给你n个派,每个派都是高为一的圆柱体,把它等分成f份,每份的最大体积是多少. 思路: 明显的二分答案题-- 注意π的取值- 3.14159265359 这样才能AC,,, //By Sirius ...
- poj 3122 (二分查找)
链接:http://poj.org/problem?id=3122 Pie Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1 ...
- POJ - 3122 Pie(二分)
http://poj.org/problem?id=3122 题意 主人过生日,m个人来庆生,有n块派,m+1个人(还有主人自己)分,问每个人分到的最大体积的派是多大,PS每 个人所分的派必须是在同一 ...
- 【POJ】3122 Pie [二分查找]
题目地址:http://poj.org/problem?id=3122 二分每块饼的体积.为了保证精度,可以先二分半径的平方r*r,最后再乘以PI.要注意一点,要分的人数要包括自己,及f+1. #in ...
- POJ 3122 Pie【二分答案】
<题目链接> 题目大意: 将n个半径不一但是高度为1的蛋糕分给 F+1个人,每个人分得蛋糕的体积应当相同,并且需要注意的是,每个人分得的整块蛋糕都只能从一个蛋糕上切下来,而不是从几个蛋糕上 ...
- POJ 3122 Pie (贪心+二分)
My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N ...
- POJ 3122 Pie(二分+贪心)
Pie Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22684 Accepted: 7121 Special Ju ...
- POJ 3122 Pie
题目大意: 给出n个pie的直径,有f+1个人,如果给每人分的大小相同(形状可以不同),每个人可以分多少.要求是分出来的每一份必须出自同一个pie,也就是说当pie大小为3,2,1,只能分出两个大小为 ...
- POJ 3104 Drying (二分+精度)
题目链接:click here~~ [题目大意]: 题意:有一些衣服,每件衣服有一定水量,有一个烘干机,每次能够烘一件衣服,每分钟能够烘掉k单位水. 每件衣服没分钟能够自己主动蒸发掉一单位水, 用烘干 ...
随机推荐
- 【初探移动前端开发04】jQuery Mobile 一
网格布局 jquery mobile提供一种多列布局功能,由于移动设备的屏幕大小原因,一般情况还是不要使用多列布局啦. jquery mobile提供一种css样式规则来定义多列布局,对应css为ui ...
- Java实现POI读取Excel文件,兼容后缀名xls和xlsx
1.引入所需的jar包: maven管理项目的话直接添加以下坐标即可: <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -- ...
- Ubuntu上开启Apache Rewrite功能的方法
Ubuntu上开启Apache Rewrite功能的方法 本文介绍ubuntn系统中开启apache的urlrewrite功能的方法. 在Windows上开启Apache的urlRewrite非常简单 ...
- VS2015运行 cordova 时候提示无法运行解决
出现此问题的原因是在于npm程序损坏了.vs调用的npm程序并不是在node安装目录下的npm,而是在: C:\Users\用户名\AppData\Roaming\Microsoft\VisualSt ...
- HDU 6119 2017百度之星初赛B 小小粉丝度度熊 (二分)
小小粉丝度度熊 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- 【SpringMVC】一次处理项目中文乱码的经历
一次处理项目中文乱码的经历 背景 今天把旧服务器上的项目转移到新服务器上,结果返回的json中的中文乱码了,觉得很奇怪,因为新服务器和旧服务器都是TX云,也不会有太大区别呀,于是乎开始了为期半天的蛋疼 ...
- Jenkins实现CI(Continuous Integration)到CD(Continuous Delivery)
Pipeline as Code是2.0的精髓所在,是帮助Jenkins实现CI(Continuous Integration)到CD(Continuous Delivery)华丽转身的关键推手.所谓 ...
- Problem E: 12306
#include <stdio.h> struct student{ int n; int m;}; int main(void) { int T; int k,g,i,j; ],max; ...
- [bzoj1010](HNOI2008)玩具装箱toy(动态规划+斜率优化+单调队列)
Description P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有 的玩具运到北京.他使用自己的压缩器进行压缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中.P教授有编号为1.. ...
- 【OpenJudge9275】【Usaco2009 Feb】【递推】Bullcow
Bullcow 总时间限制: 12000ms 单个测试点时间限制: 1000ms 内存限制: 131072kB [描述] 一年一度的展会要来临了,农民约翰想要把N(1 <= N <= 10 ...