标签:
心情不好,简单的二分
#include<iostream> #include<cstdio> #include<cmath> using namespace std; double y; int cal(double x) { return 8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*x+6; } double find() { double mid; double a,b; a=0;b=100; while(b-a>1e-8) { mid=(a+b)/2; if(cal(mid)<y) a=mid; else b=mid; } return (a+b)/2.0; } int main() { int t; cin>>t; while(t--) { cin>>y; if(cal(0)<=y&&y<=cal(100)) printf("%.4f\n",find()); else cout<<"No solution!"<<endl; } return 0; }
hdu 2199 Can you solve this equation
标签:
原文地址:http://blog.csdn.net/zafkiel_nightmare/article/details/44964279