Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 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!
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std; #define ll long long
#define db double
const int Len = 1e5+10; db Cal(db m)
{
return 8 * pow(m, 4) + 7 * pow(m, 3) + 2 * pow(m, 2) + 3 * m + 6;
} int main()
{
//freopen("A.txt","r",stdin);
int t;
cin >> t;
while(t --)
{
int n;
scanf("%d", &n);
db l = 0, r = 100;
if(Cal(0) > n || Cal(100) < n)
cout << "No solution!\n";
else
{
db m;
while(r - l >= 1e-10)
{
m = (l + r)/2;
if(Cal(m) > n)
r = m;
else
l = m;
}
printf("%.4lf\n", m);
}
} return 0;
}

最新文章

  1. CentOS 7.2安装docker-compose运行gitlib
  2. WP8.1 C#代码 添加/获取Grid.ColumnDefinitions/RowDefinitions
  3. JavaScript数据属性与访问器属性
  4. Python笔记——类定义
  5. mysql-模拟全连接处理
  6. 2016年6月27日 星期一 --出埃及记 Exodus 14:24
  7. json与jsonp应用及其他ajax数据交互方式
  8. CSS3制作苹果风格键盘
  9. 【C++基础】 指针&amp;字符串&amp;数组
  10. C/C++输入输出总结
  11. OOP三类继承的区别
  12. angular2 学习笔记 ( Http 请求)
  13. update语句的执行步骤及commit语句的执行顺序
  14. 利用JS跨域做一个简单的页面訪问统计系统
  15. noip模拟 市长选举
  16. 《NET 设计规范》第 2 章 框架设计基础
  17. pyhton图片合成模块-PIL
  18. Oracle创建表空间创建用户和用户授权
  19. posix信号量与互斥锁
  20. CDH 5.16.1 离线部署 &amp; 通过 CDH 部署 Hadoop 服务

热门文章

  1. DUBBO 面试灵魂18问
  2. springboot1.5.9整合websocket实现实时显示的小demo
  3. Java实现生产者消费者(一)
  4. MySQL敏感数据加密及解密
  5. javaee作业
  6. Redis(9)——史上最强【集群】入门实践教程
  7. 量化学习 | Tushare 基本面选股 (二)
  8. 【TIJ4】第五章全部习题
  9. Python科学计算库SymPy初探
  10. Docker学习-私有仓库docker-registry的使用