poj 3122 Pie 二分答案
来源:互联网 发布:淘宝网厨房用品面具 编辑:程序博客网 时间:2024/05/20 06:04
题目地址: http://poj.org/problem?id=3122
还是找到了单调函数--分给m人对最大尺寸f(m) 是m的不增函数,那么具体给定m是,二分f(m)使用>=f+1 l=mid 而不是>来保证尽可能取得大
细节: 应该直接二分答案,而不是算出比较精确的半径平方,最后*PI输出,会产生误差,然后PI用arccos(-1),否则也会wa
代码:
#include<iostream>#include<cstdio>#include<cmath>using namespace std;//const double PI=3.1415926535; //这样写就wa了 是精度不够?const double PI=acos(-1.0);int N,F;int a[10005];long long person_num(double x){ long long ans=0; for(int i=0;i<N;i++) { ans+=a[i]*a[i]*PI/x; } return ans;}int main(){ int T; cin>>T; while(T--) { double max_size=0; cin>>N>>F; double l=0,r=1000000000; // 10000,0000 小了 double mid; while(r-l>=1e-4) { mid=(l+r)/2; if(person_num(mid)>=F+1) l=mid; else r=mid; } printf("%.4lf\n",l); }}
- 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(二分)
- poj 3122 pie(二分搜索)
- poj 3122&&hdu1969 Pie(二分)
- poj 3122 Pie (二分查找)
- ACMICPC 2013 长沙 F 题Curve in Circle
- Android逆向分析必备网址大全
- cc1plus: warnings being treated as errors
- CocoaPods 安装 及 简单的应用
- android工具集-android安全
- poj 3122 Pie 二分答案
- android camera 竖直拍照 获取竖直方向照片 做缩放处理
- C# 枚举转换操作
- oracle 交集和并集
- cocos studio
- oracle 递归查询
- 使用 MonoDevelop 调试 Unity3D 的正确步骤
- JAP1.0移植到JAP2.0时 其中涉及到Date,TimeStamp的需要添加@Temporal
- 25 - Divide Two Integers