【POJ】3122 Pie [二分查找]】的更多相关文章

链接:http://poj.org/problem?id=3122 Pie Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10448   Accepted: 3694   Special Judge Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N…
题目地址:http://poj.org/problem?id=3122 二分每块饼的体积.为了保证精度,可以先二分半径的平方r*r,最后再乘以PI.要注意一点,要分的人数要包括自己,及f+1. #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> using namespace std; ; const double PI…
题目:http://poj.org/problem?id=3122 这个题就好多了,没有恶心的精度问题,所以1A了.. #include <stdio.h> #include <math.h> ); ], t, n, m; int main() { scanf("%d", &t); while(t--) { , high = ; scanf("%d %d", &n, &m); ; i < n; i++) { sc…
Pie Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13564   Accepted: 4650   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…
题意:给你n个派,每个派都是高为一的圆柱体,把它等分成f份,每份的最大体积是多少. 思路: 明显的二分答案题-- 注意π的取值- 3.14159265359 这样才能AC,,, //By SiriusRen #include <cstdio> using namespace std; int n,f,cases,a[10050]; double v[10050]; bool check(double x){ int ans=0; for(int i=1;i<=n;i++)ans+=v[i…
题目大意: 给出n个pie的直径,有f+1个人,如果给每人分的大小相同(形状可以不同),每个人可以分多少.要求是分出来的每一份必须出自同一个pie,也就是说当pie大小为3,2,1,只能分出两个大小为2的份,剩下两个要扔掉. 解题思路: 对每一个人分的大小进行二分查找,注意输出要用cout. 下面是代码: #include <stdio.h> const double pi=3.14159265359; const double esp=1e-6; int main() { int T; sc…
题目链接: http://poj.org/problem?id=2452 题意:在区间[1,n]上找到满足 a[i]<a[k]<a[j] (i<=k<=j) 的最大子区间 (j-i)如不存在输出 -1. 思路:枚举i,找到 i右边第一个不大于(不是小于) a[i]的数a[k](二分查找+RMQ某段区间的最小值是否小于a[i].最后确定到一个点),于是我们可以得到在区间[i,k-1]范围内的数都会大于 a[i] ,所以对于下标i,它对应的最长区间必定在[i,k-1]之间. 所以,我们…
二分查找是一个非常主要的算法,针对的是有序的数列,通过中间值的大小来推断接下来查找的是左半段还是右半段,直到中间值的大小等于要找到的数时或者中间值满足一定的条件就返回,所以当有些问题要求在一定范围内找到一个满足一些约束的值时就能够用二分查找,时间复杂度O(log n); 题目:http://acm.hit.edu.cn/hoj/problem/view?id=2651 由于题目有精度要求,对于浮点数小数点部分会有一定误差,所以能够选择将这些有小数部分的数值扩大e6倍,由于题目要求精确到e-3,之…
http://poj.org/problem?id=3122 题意 主人过生日,m个人来庆生,有n块派,m+1个人(还有主人自己)分,问每个人分到的最大体积的派是多大,PS每 个人所分的派必须是在同一个派上切下来的. 分析 二分答案,每次统计当前体积下能分配的人数. #include<iostream> #include<cmath> #include<cstring> #include<queue> #include<vector> #incl…
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…