博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDUOJ---Can you solve this equation?
阅读量:5927 次
发布时间:2019-06-19

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

Can you solve this equation?

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 5667    Accepted Submission(s): 2681

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.
 

 

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
2 100 -4
 

 

Sample Output
1.6152 No solution!
 

 

Author
Redow
 

 

Recommend
lcy
二分搜索
代码:
#include
#include
#define sum(x) ((8*x*x*x*x)+(7*x*x*x)+(2*x*x)+(3*x)+(6))using namespace std;int main(){ int t; double y,mid,left,right; cin>>t; while(t--) { scanf("%lf",&y); left=0.0,right=100.0; if(y>=6.0&&y<=sum(100)) { while(right-left>1e-8) { mid=(left+right)/2.0; if(sum(mid)-y>1e-8) right=mid; else if(y-sum(mid)>1e-8) left=mid; else break; } printf("%.4lf\n",mid); } else puts("No solution!"); } return 0;}

 

转载地址:http://wvhvx.baihongyu.com/

你可能感兴趣的文章
还原企业员工对SaaS产品误解的真相
查看>>
设置vim语法着色和缩进
查看>>
poj 1014 dividing(本解法可ac 但错误!!!)
查看>>
mysql全备份脚本
查看>>
HTML处理oc代码
查看>>
System.arraycopy 方法处理数组
查看>>
linux和windows上路径问题
查看>>
Angular-限定$scope的范围
查看>>
按键神通(按键神通官方下载)V2.0官方版
查看>>
简历4(三年工作以后)
查看>>
Navicat for SQL Server 高级属性(状态)
查看>>
boost中asio的deadline_timer异步调用示例
查看>>
字符串的拼接-MYSQL
查看>>
Centos上安装Docker管理器Docker Compose
查看>>
各种算法和数据结构的复杂度
查看>>
EZ-430 Chronos 的相关参数
查看>>
Sqrt(x)
查看>>
homebrew cask安装launchrocket
查看>>
关于listview的item的点击事件的各个参数使用
查看>>
WDCP忘记面板后台登录密码找回方法
查看>>