二分-D - Can you solve this equation?
2024-10-08 09:32:38
D - Can you solve this equation?
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.InputThe 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);OutputFor 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
2
100
-4Sample Output
1.6152
No solution!
#include<iostream>
#include<cmath>
using namespace std; double f(double x){
return (*pow(x,) + *pow(x,) + *pow(x,) + *x + );
} int main()
{
int t;
double m,n;
scanf("%d",&t);
while(t--){
scanf("%lf",&m);
if(f()>m||f()<m){
printf("No solution!\n");
continue;
}
double left = , right = , mid;
while(fabs(f(mid)-m) > 1e-){
mid=(left + right)/;
if((f(mid) > m)) right = mid;
else if(f(mid)<m) left=mid;
}
printf("%.4lf\n",mid);
}
return ;
}
最新文章
- Python的垃圾回收机制
- ajax 和 post 传多个参数值具体怎么写
- comboBox的id返回System.Data.DataRowView
- meta是什么意思?
- Java SE/ME/EE的概念介绍
- android开发学习笔记:圆角的Button
- HDOJ(HDU) 1985 Conversions(汇率转换)
- 一封推荐信——android培训机构
- Openlayer 3 的点击弹出框
- 关于Lt分发系统的时序图分析
- 如何在SpriteBuilder中设置对象的通用属性
- Android初级教程以动画的形式弹出窗体
- 05python上
- 学习Junit资料
- CSS特效(弧光效果)
- Linux笔记 #07# 搭建机器学习环境
- Spark(十五)SparkCore的源码解读
- 共享内存简介和mmap 函数
- Spring AOP声明式事务异常回滚(转)
- WOL*LAN远程换醒命令行方法