博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 2199又是一道二分答案的题
阅读量:4514 次
发布时间:2019-06-08

本文共 1160 字,大约阅读时间需要 3 分钟。

这都是今天做的第三道二分答案的题了。。。这题精度控制要求也比较高,我是把eps设成1e-8才过的1e-6都过不了。。。

/* * hdu2199/win.cpp * Created on: 2012-11-2 * Author    : ben */#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;const double eps = 0.00000001;const double LOW = 6 - eps;const double HIGH = 807020306 + eps;inline double getresult(double x) { double xx = x * x; double xxxx = xx * xx; return 8 * xxxx + 7 * x * xx + 2 * xx + 3 * x + 6;}double getans(double y) { double low = 0, high = HIGH, mid; while(high - low > eps) { mid = (low + high) / 2; if(getresult(mid) - y < eps) { low = mid; }else { high = mid; } } return mid;}int main() {#ifndef ONLINE_JUDGE freopen("data.in", "r", stdin);#endif int T; double y; scanf("%d", &T); while(T--) { scanf("%lf", &y); if(y < LOW || y > HIGH) { puts("No solution!"); continue; } double ans = getans(y); printf("%.4f\n", ans); } return 0;}

转载于:https://www.cnblogs.com/moonbay/archive/2012/11/02/2751732.html

你可能感兴趣的文章
NodeJS基础教程之一
查看>>
你真的了解SDWebImage吗?
查看>>
BZOJ 1101 Luogu P3455 POI 2007 Zap (莫比乌斯反演+数论分块)
查看>>
C#嵌套类
查看>>
2017《面向对象程序设计》课程作业三
查看>>
[HDU] 1068 Girls and Boys(二分图最大匹配)
查看>>
ADO.NET类的模型关系图
查看>>
SRM 604 DIV2 250
查看>>
python中异常处理之esle,except,else
查看>>
看苹果官方API
查看>>
06-基础-系统指令-v-model-语法糖原理
查看>>
论文网站相关链接
查看>>
死锁,死锁必要条件及处理策略
查看>>
Kinect for windows
查看>>
Java EE Map
查看>>
Hadoop源代码点滴-文件系统HDFS
查看>>
单个页面Request编码方式的改变,无需改动Web.config~
查看>>
SQL Server中的窗口函数
查看>>
【Alpha】Daily Scrum Meeting第十次
查看>>
戴尔Inspiron N4120 笔记本电脑安装XP、win7双系统过程
查看>>