博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU2199:Can you solve this equation?(数学 + 二分)
阅读量:6996 次
发布时间:2019-06-27

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

Can you solve this equation?

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 19065    Accepted Submission(s): 8406


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
思路:二分解方程。
# include 
# include
double fun(double x){ return 8*x*x*x*x + 7*x*x*x + 2*x*x + 3*x + 6;}int main(){ int t; double y, l, r; scanf("%d",&t); while(t--) { scanf("%lf",&y); if(y
fun(100)) { puts("No solution!"); continue; } l = 0; r = 100; double mid = (l+r)/2; while(fabs(fun(mid)-y)>1e-6) { if(fun(mid)

转载于:https://www.cnblogs.com/junior19/p/6730050.html

你可能感兴趣的文章
MaxCompute Studio 使用入门
查看>>
linux进程介绍
查看>>
nginx服务器出现504 gateway time-out怎么解决
查看>>
Java-实现链表的基本操作
查看>>
部署android开发环境总结
查看>>
我的友情链接
查看>>
利用makefile构建c++项目的思路介绍
查看>>
ssh的反向隧道
查看>>
F5 DDoS防御小妙招:减轻DDoS***危害的六大最佳方法
查看>>
echo
查看>>
MariaDB,MySQL中存储过程的学习笔记
查看>>
一张图诠释linux系统启动过程
查看>>
载入jQuery库的最佳方法
查看>>
系统错误提示修复Repair Filesystem
查看>>
【DAY20】Socket编程的补充2
查看>>
Openstack 网络服务Neutron [五]
查看>>
如何看硬盘SMART参数----用HDtune工具查看
查看>>
PUTTY使用Ctrl+s僵死的问题
查看>>
验证码识别技术研究
查看>>
WSDL文件生成java类
查看>>