hdoj 2199 Can you solve this equation? 【二分枚举】
2014-08-25 08:21
399 查看
题意:给出一个数让你求出等于这个数的x
策略:如题。因为整个式子是单调递增的,所以可以用二分。
要注意到精度.
代码:
策略:如题。因为整个式子是单调递增的,所以可以用二分。
要注意到精度.
代码:
#include <stdio.h> #include <string.h> #include <math.h> #define eps 1e-10 #define f(x) 8*pow(x, 4) + 7*pow(x, 3) + 2*pow(x, 2) + 3*x int main() { int t; double n; scanf("%d", &t); while(t --){ scanf("%lf", &n); n-=6; double max = f(100); if(n<0||n>max){ printf("No solution!\n"); continue; } double left, right, mid; left = 0; right = 100; while(right-left > 1e-7){ //精度要小于1e-7, mid = (left+right)/2; double temp = f(mid); if(temp < n) left = mid+1e-7; else right = mid; } printf("%0.4lf\n", left); } return 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?【浮点型数据二分】
- hdoj2199 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 题目2199Can you solve this equation?(二分搜索)
- hdoj 2199 Can you solve this equation? 【二分查找】
- 文章标题 HDU 2199 : Can you solve this equation?(二分)
- HDOJ--2199 Can you solve this equation?(附题意)
- HDU 2199 Can you solve this equation(二分水题)
- HDU:2199 Can you solve this equation?(二分)
- HDU - 2199 Can you solve this equation? (二分)
- HDU—2199—Can you solve this equation?—【二分】【精度控制】
- HDOJ - 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation(二分水题)
- hdu 2199 Can you solve this equation? 二分
- hdoj-2199-Can you solve this equation? (二分法)