【hdu2199】Can you solve this equation?——二分
来源:互联网 发布:c语言完全手册pdf下载 编辑:程序博客网 时间:2024/06/10 21:54
题目:
Can you solve this equation?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15110 Accepted Submission(s): 6739
Problem Description
Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100;
Now please try your lucky.
Now please try your lucky.
Input
The first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines follow, each line has a real number Y (fabs(Y) <= 1e10);
Output
For each test case, you should just output one real number(accurate up to 4 decimal places),which is the solution of the equation,or “No solution!”,if there is no solution for the equation between 0 and 100.
Sample Input
2100-4
Sample Output
1.6152No solution!
Author
Redow
描述:求方程的解
题解:二分裸题
代码:
#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>using namespace std;const double eps = 1e-10;double f(double x){return 8.0 * pow(x,4) + 7 * pow(x,3) + 2 * pow(x,2) + 3 * x + 6;}int main(){//freopen("input.txt", "r", stdin);int T;scanf("%d", &T);while (T--){double Y;scanf("%lf", &Y);double l = 0.0;double r = 100.0;if (f(l) > Y || f(r) < Y){printf("No solution!\n");continue;}while (r - l > eps){double mid = (l + r) / 2;if (f(mid) > Y)r = mid;elsel = mid;}printf("%.4lf\n", r);}return 0;}
0 0
- 【hdu2199】Can you solve this equation?——二分
- HDU2199:Can you solve this equation?(二分)
- HDU2199 Can you solve this equation?(二分)
- (step4.1)hdu2199(Can you solve this equation?——二分查找)
- ACM-二分搜索之Can you solve this equation?——hdu2199
- hdu2199 Can you solve this equation? (二分搜索)
- hdu2199 Can you solve this equation? (二分+double精度)
- hdu2199 Can you solve this equation?(二分)
- HDU2199:Can you solve this equation?(数学 + 二分)
- 二分搜索--控制精度--hdu2199 Can you solve this equation
- HDU2199 Can you solve this equation?
- hdu2199 Can you solve this equation?
- HDU2199 Can you solve this equation?
- hdu2199 Can you solve this equation?
- HDU2199.Can you solve this equation?——二分解方程
- HDU2199 Can you solve this equation 二分求方程的根
- hdu2199 Can you solve this equation?(二分查找,多项式求解)
- 【个人训练】(HDU2199)Can you solve this equation?
- 各种排序算法(c)及时间复杂度分析
- Android-使用框架布局管理器居中显示层叠的正方形
- CALayer遮罩效果
- 随堂笔记160307静态代码块设计模式
- Unity3D 5 官方教程:标准着色器之材质参数(二)
- 【hdu2199】Can you solve this equation?——二分
- 使用基于ThinkPHP3.2.3的ThinkAdmin创建手机电脑通用的表白墙(九)后台实现:整体概述
- setWindowFlags(Qt::FramelessWindowHint);使得窗体透明的问题解决
- 第一次C++作业-2
- 随堂笔记160308继承
- Java开发中的23种设计模式详解(转)
- 老罗Handler(22)各种方式发送handler以及发送更多类型数据给主线程
- 算法基础:递归---汉诺塔问题
- 最短路径Dijkstra算法