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! "); 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 ",r); } } return 0; }