POJ 3122 Pie(二分答案)
来源:互联网 发布:执业兽医资格考试软件 编辑:程序博客网 时间:2024/05/20 09:44
this is the question
to solve this , we should use some method called binary search the solution , when we examine one possible answer , we see if the ans ( pie size) and be depart to all the friends.
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#define ll long long#define eps 1e-9#define trace printf("here\n");using namespace std;const int maxn = 100005;const double PI = acos(-1.0);int n,m;double pie[maxn];bool check(double x){ int cnt = 0; for(int i=0;i<n;i++) { cnt+=(int)floor(pie[i]/x); } //cout<<cnt<<endl; if(cnt<m) return false; else return true;}int main(){ int ca = 0; scanf("%d",&ca); while(ca--) { scanf("%d%d",&n,&m); m++; double mn = 0; double sum = 0; for(int i=0;i<n;i++) { int r; scanf("%d",&r); pie[i] = r*r*PI; sum+=pie[i]; mn = max(pie[i],mn); } //sort(pie,pie+n);// for(int i=0;i<n;i++)// {// cout<<pie[i]<<endl;// } double l = mn/m ,r = sum/m ; while( l+0.00001 < r ) { double mid = (l+r)/2; if(check(mid)) l =mid; else r = mid; } printf("%.4f\n",l); } return 0;}
阅读全文
0 0
- POJ 3122 Pie(二分答案)
- poj 3122 Pie 二分答案
- POJ 3122 Pie【二分答案】
- POJ 3122 Pie 二分答案
- [POJ 3122] Pie 二分答案+贪心
- POJ 3122 Pie(二分)
- POJ 3122 Pie (二分)
- poj 3122 Pie(二分)
- POJ 3122 Pie 二分
- POJ 3122 Pie 二分
- poj 3122 Pie (二分)
- Pie - POJ 3122 二分
- POJ 3122 Pie(二分)
- POJ 3122pie(二分)
- POJ 3122 pie 二分
- [poj 3122] Pie 二分
- POJ Pie 3122 (二分)
- POJ 3122 - Pie(二分)
- 500 G JAVA视频网盘分享
- 自己动手写PHP MVC框架
- 通过xStream读取xml文件生成Java对象和Java对象生成xml文件
- 比较的简单的二叉树的练习代码(纯属娱乐)
- python数据结构-队列
- POJ 3122 Pie(二分答案)
- AndroidStudio配置SVN
- 如何切换Python2与Python3
- Error:The SDK Build Tools revision (24.0.3) is too low for project ':app'
- HDU 6130 Kolakoski【】
- 德国工业考察之拜访3S公司
- KMP-最小矩阵
- Unity中InSpector重写问题
- Modbus编程测试,保持寄存器首个寄存器运行一段时间后为0