HDOJ 2199 Can you solve this equation?
来源:互联网 发布:网络语柚子是什么意思 编辑:程序博客网 时间:2024/06/05 17:53
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2199
题目大意:有一个方程8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,现在给定Y,求x的近似值,结果保留4位小数。
题目思路:很容易看出来,这个函数是单调递增函数,所以我们直接二分答案。
AC代码:
// HDOJ// 2199.cpp/* ID: Firwaless LANG: C++ TASK: Can you solve this equation?*/#include <cstdio>#include <cmath>#define eps 1e-10double value(double x){ return 8 * pow(x, 4) + 7 * pow(x, 3) + 2 * pow(x, 2) + 3 * x + 6;}int main(){ int n; double x, y, l, r, mid; while (~scanf("%d", &n)) { while (n--) { scanf("%lf", &y); l = 0; r = 100; if (value(0) > y || value(100) < y) { puts("No solution!"); } else { while (r - l > eps) { mid = (l + r) / 2; x = value(mid); if (x < y) { l = mid + eps; } else { r = mid - eps; } } printf("%.4lf\n", mid); } } } return 0;}
0 0
- HDOJ 2199 Can you solve this equation?
- hdoj 2199 Can you solve this equation?
- HDOJ 2199 Can you solve this equation?
- HDOJ 2199 Can you solve this equation?
- HDOJ 2199 Can you solve this equation?
- HDOJ-2199 Can you solve this equation?
- HDOJ - 2199 Can you solve this equation?
- HDOJ 2199 Can you solve this equation?
- hdoj 2199 Can you solve this equation?【二分查找】【水】
- HDOJ--2199--Can you solve this equation?【二分法】
- hdoj-2199-Can you solve this equation? (二分法)
- HDOJ 2199 Can you solve this equation?(二分查找法)
- hdoj 2199 Can you solve this equation? 【二分枚举】
- HDOJ-2199-Can you solve this equation?(二分查找)
- HDOJ Can you solve this equation? 2199【二分查找】
- HDOJ 2199 Can you solve this equation?(二分)
- HDOJ 2199 Can you solve this equation?(二分查找)
- hdoj-2199Can you solve this equation?【二分】
- 亮一下我的配置
- i2c-tools-3.1.0的使用
- 如何配note,打补丁
- 关于固定资产的分录
- 命令行标准
- HDOJ 2199 Can you solve this equation?
- 文件夹的拷贝
- GCC 中 undefined reference to ‘ceil’ collect2:ld returned 1 exit status 错误
- Opencv 例程讲解 6 ---- 图片融合 addWeighted到底有多快?
- 电源管理之android内核suspend to disk的实现(一)
- Hibernate Annotation @mappedBy含义
- 【LeetCode】48 Rotate Image && 【九度】题目1164:旋转矩阵
- WebClient与WebRequest差异
- linux常用命令