Can you solve this equation?
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.
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);
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.
-4
solution!
#include
using namespace std;
double iteration(double x)
{
double
fx;
fx=8*x*x*x*x+7*x*x*x+2*x*x+3*x+6;
return
fx;
}
int main()
{
//freopen("in.txt", "r", stdin);
int n;
double
y,x1,x2,x;
scanf("%d",&n);
for(int
i=0;i
{
scanf("%lf",&y);
x1=-1;
x2=101;
if(y<6||y>807020306)
{
printf("No solution!\n");
continue;
}//最大解和最小解判断有没有解
else
{
while(true)
{
x=(x1+x2)/2;
if(x2-x1<1e-6)//这里精度最小就得是1e-6
{
printf("%.4lf\n",x);
break;
}
else
{
if(iteration(x)==y)
{
printf("%.4lf\n",x);
break;
}
else if(iteration(x)
x1=x;
else if(iteration(x)>y)
x2=x;
}
}
}
}
return 0;
}
Can you solve this equation?的更多相关文章
- ACM:HDU 2199 Can you solve this equation? 解题报告 -二分、三分
Can you solve this equation? Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Su ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdu 2199:Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdu 2199 Can you solve this equation?(高精度二分)
http://acm.hdu.edu.cn/howproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS ...
- HDU 2199 Can you solve this equation? (二分 水题)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdoj 2199 Can you solve this equation?【浮点型数据二分】
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- Can you solve this equation?(二分)
Can you solve this equation? Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Ja ...
- Can you solve this equation?
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- HDU 2199 Can you solve this equation(二分答案)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU - 2199 Can you solve this equation? 二分 简单题
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- Android Studio安装应用时报错 installation failed with message Failed to finalize session......
解决方法: 在AndroidManifest.xml中的provider中的authorities后加几个数字即可. 2017.09.01: 我发现有的项目AndroidManifest.xml中没有 ...
- Java历程-初学篇 Day08 数组
一,什么是数组 所谓数组,是相同数据类型的元素按一定顺序排列的集合.若将有限个类型相同的变量的集合命名,那么这个名称为数组名.组成数组的各个变量称为数组的分量,也称为数组的元素,有时也称为下标变量.用 ...
- centos7基础学习第一天
Linux是一个操作系统: 智能手机,Android和ios.Windows: 网站.游戏.QQ.微信等都是运行在Linux系统之上的应用:客户端.服务器端交互的: Linux的起源: Linux之前 ...
- python之testcenter操作
一.设置python环境 1. 从以下路径中将StcPython.py文件拷贝出来 Linux: /Installdir/Spirent_TestCenter_4.xx/Spirent_TestCen ...
- Java面向对象 异常
Java面向对象 异常 知识概要: (1)异常的概述 (2)异常的体系 (3)异常的处理 ...
- 51nod 1522 上下序列
题目描述 现在有1到n的整数,每一种有两个.要求把他们排在一排,排成一个2*n长度的序列,排列的要求是从左到右看,先是不降,然后是不升. 特别的,也可以只由不降序列,或者不升序列构成. 例如,下面这些 ...
- 阿里巴巴 Java 开发规约插件初体验
阿里巴巴 Java 开发手册 又一次来谈<阿里巴巴 Java 开发手册>,经过这大半年的版本迭代,这本阿里工程师们总结出来避免写出那么多 Bug 的规范,对于 Java 开发者简直就是必备 ...
- 近期面试总结(PHP后端开发工程师)(部分笔试题)
1.字符串"0"在PHP和js中转换为布尔值是false还是true php:false; php 弱语言 '0'和0一样: js:true:字符串除了空字符串('')其他都是tr ...
- win10 UWP 圆形等待
看到一个圆形好像微软ProgressRing 我们可以用自定义控件 按ctrl+shift+a 用户控件 我们可以用Rectangle做圆形边 只要Rectangle RadiusX>0圆角 因 ...
- Coursera_程序设计与算法_计算导论与C语言基础_数组应用练习
您也可以在我的个人博客中阅读此文章:跳转 编程题#1:求字母的个数 描述 在一个字符串中找出元音字母a,e,i,o,u出现的次数. 输入 输入一行字符串(字符串中可能有空格,请用gets(s)方法把一 ...