hdu2199(高精度二分模版)
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.
Now please try your lucky.
#include<iostream> #include<math.h> #include<stdio.h> using namespace std; double deal(double x) { return 8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*x+6; } int main() { int t; scanf("%d",&t); while(t--) { double x,sum,l=0,r=100; scanf("%lf",&sum); if(sum<deal(0)||sum>deal(100.0)) { printf("No solution!\n"); continue; } else { double mid; int flg=0; while(r-l>1e-6) { mid=(l+r)/2; if(deal(mid)>sum) r=mid; else l=mid; } printf("%.4lf\n",r); } } return 0; }
朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。