Can you solve this equation?

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 61   Accepted Submission(s) : 37
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!
 
题解:二分法
代码:
 #include<stdio.h>
double abs(double x){
return x>?x:-x;
}
double operate(double x){
return *x*x*x*x+*x*x*x+*x*x+*x+6.0;
}
double search(double y){
double l=,r=,mid;
while(r-l>1e-){mid=(l+r)/;
if(operate(mid)<y)l=mid;
else r=mid;
if(abs(operate(mid)-y)<1e-)break;
}
return mid;
}
int main(){
int T;
double Y;
scanf("%d",&T);
while(T--){
scanf("%lf",&Y);
if(Y<operate()||Y>operate())puts("No solution!");
else printf("%.4lf\n",search(Y));
}
return ;
}

Can you solve this equation?(二分)的更多相关文章

  1. HDU 2199 Can you solve this equation? (二分 水题)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  2. HDU - 2199 Can you solve this equation? 二分 简单题

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  3. HDU 2199 Can you solve this equation?(二分精度)

    HDU 2199 Can you solve this equation?     Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == ...

  4. hdu 2199 Can you solve this equation? 二分

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  5. 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 ...

  6. HDU 2199 Can you solve this equation(二分答案)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  7. hdu2199Can you solve this equation?(解方程+二分)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  8. 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 ...

  9. hdoj 2199 Can you solve this equation?【浮点型数据二分】

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

随机推荐

  1. python 得到一个元素的所有下标(网友提供:http://www.oschina.net/code/snippet_212212_38917)

    def all_index(l,o): def find_index(l,o,start=0): try: index=l.index(o,start) except: index=-1 return ...

  2. pyqt说明

    我是个PHP程序员,不过有时候觉得需要写些小软件,对于我这种不太熟悉桌面软件开发的人来说,界面问题最让我头痛.听说Qt很强大,而且是跨平台,所以决定学习它用来弥补我写桌面软件的不足. Qt一般是通过C ...

  3. 地下迷宫(bfs输出路径)

    题解:开一个pre数组用编号代替当前位置,编号用结构题另存,其实也可以i*m+j来代替,我写的有点麻烦了; 代码: #include <iostream> #include <cst ...

  4. blockUI

    组件主页 主要使用到 blockUI 组件实现 将jquery和组件的JS下载到本地 然后直接就可以实现遮罩层功能 显示遮罩层:$.blockUI(); 隐藏遮罩层:$.unblockUI(); 该网 ...

  5. drwtsn32.exe 遇到问题须要关闭。我们对此引起的不便表示抱歉

    我的机器老是这样.启动起来就有这个... 那位高手能告诉我这是怎么会事.故障的原因以及解决的办法. 最佳答案 drwtsn32.exe是windows的一项磁盘检查程序,同一时候也是鸡肋程序,最好的办 ...

  6. DOS 选择跳转实现、dos + bcp 双击导入和导出数据

    DOS 选择跳转实现.dos + bcp 双击导入和导出数据 option.bat @echo off :Start2 cls goto Start :Start title Frequently U ...

  7. css-文本及其他

    <!DOCTYPE html>css7-文本和其他 text-align行内元素对齐方式,值为 左/中/右 对齐:left/right/center.test{text-align:cen ...

  8. ie11加载不了css的问题

    ie11打开页面,竟然一点css都没有加载出来,而且是老大的电脑遇到了这个问题,啃爹啊 上网查资料,做了如下修改: 1.pc端最好不要用h5来写页面,兼容性是个头疼的问题,切记切记(移动端可以用H5来 ...

  9. Android Studio 导入Eclipse工程

    eclipse:workspace对应多个project:而android studio是project对应多个module:故,在android studio中的工程project实际上是eclip ...

  10. BOM 窗体相关属性以及页面可见区域的获取方式

    1 在IE Safari Oper Chrome 都提供了screenLeft和screenTop属性: screenLeft : 相对于屏幕左边的距离 screenTop : 相对于屏幕上边的距离 ...