hdu 2199 Can you solve this equation?
来源:互联网 发布:绘画软件价格 编辑:程序博客网 时间:2024/05/29 19:46
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2199
题目大意:找到满足8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y的x值,注意精确度问题。
1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 5 using namespace std; 6 7 8 double fun(double s) 9 {10 return 8*pow(s, 4.0) + 7*pow(s, 3.0) + 2*pow(s, 2.0) + 3*s + 6;11 }12 int main ()13 {14 int t,flag;15 cin>>t;16 while (t--)17 {18 flag=0;19 double x,y,yy,r,l;20 cin>>y;21 if (fun(0)<=y&&fun(100)>=y)22 {23 r=0,l=100;24 while (l-r>1e-6)25 {26 //cout<<r<<endl;27 x=(r+l)/2;28 double yy=fun(x);29 //yy=8*x*x*x*x+7*x*x*x+2*x*x+3*x+6;30 //yy=8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*x+6;31 if (yy>y)32 l=x+1e-7;33 else34 r=x+1e-7;35 36 }37 printf ("%.4lf\n",(r+l)/2);38 //break;39 flag=1;40 }41 else42 {printf ("No solution!\n");flag=1;}43 if (yy==r&&flag==0)44 printf ("%.4lf\n",y);45 else if (flag==0)46 printf ("No solution!\n");47 48 }49 return 0;50 }
0 0
- hdu 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- HDU 2199-Can you solve this equation?
- hdu 2199 Can you solve this equation?
- hdu 2199 can you solve this equation
- HDU 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation
- hdu-2199 Can you solve this equation?
- hdu 2899 Strange fuction (二分)
- hdu 2817 A sequence of numbers(快速幂取余)
- hdu 1358 Period
- 冒泡排序
- hdu 3746 Cyclic Nacklace
- hdu 2199 Can you solve this equation?
- 17.1.2.1 Advantages and Disadvantages of Statement-Based and Row-Based Replication
- hdu 1686 Oulipo (kmp)
- hdu 1711 Number Sequence
- 最受欢迎的5个Android ORM框架
- hdu 1399 Starship Hakodate-maru (暴力搜索)
- hdu 3003 Pupu
- js字符串函数(split、join、indexOf、substring)
- hdu 4506 小明系列故事——师兄帮帮忙