poj 3122
来源:互联网 发布:js 几秒刷新一次 编辑:程序博客网 时间:2024/05/16 11:48
精度的原因,开始一直错,我这数学白痴学习了!
#include <iostream>#include <cstring>#include <cstdio>#include <math.h>#include <cstdlib>#include <algorithm>using namespace std;#define PI acos(-1.0)#define eps 1e-7double a[20500];int main (){int t;scanf("%d",&t);while(t--){int n,f;double left=0.0,right=1000000000.0;scanf("%d%d",&n,&f);f++;for(int i=1;i<=n;++i){scanf("%lf",&a[i]);a[i]=PI*a[i]*a[i];//if(right>a[i])//right=a[i];}while(right-left>eps){double mid=(left+right)/2;int p=0;for(int i=1;i<=n;++i){int times=a[i]/mid+(1e-12); // 为防止小数部分出现0.999999// 加的数要足够小, 1e-8居然还WA!!p+=times;}if(p>=f)left=mid;else right=mid;}printf("%lf\n",left);}return 0;}
- poj 3122
- POJ 3122
- poj 3122
- poj 3122
- poj 3122
- POJ 3122
- POJ 3122
- poj 3122
- poj 3122
- poj 3122
- POJ-3122 Pie
- POJ 3122 Pie 二分
- POJ 3122 Pie 二分
- poj 3122 pie
- POJ 1905,3122,3273
- POJ 3122 Pie
- poj 3122 la3635 pie
- POJ 3122 Pie
- servlet总结
- Struts2类型转换详解
- POJ 1948
- windows系统下c语言暂停程序
- Android ListView 实现 GridView 用以实现GridView的下拉刷新
- poj 3122
- POJ2109--Power of Cryptography
- Java 夹杂文本字段的文件上传 后台实现(包括前端jquery实现的备忘)
- 关于list集合的remove和Iterator的remove
- 网页配色网站
- Python的常用库
- linux内存管理学习笔记
- 4clojure第43个问题逆向交错(Reverse Interleave)
- android学习笔记