1 #include<bits/stdc++.h> 2 using namespace std; 3 double eps = 1e-6; 4 double f(double x) 5 { 6 return (42 * pow(x, 6) + 48 * pow(x, 5) + 21 * pow(x, 2) + 10 * x); 7 } 8 double F(double x, double y) 9 { 10 return (6 * pow(x, 7) + 8 * pow(x, 6) + 7 * pow(x, 3) + 5 * pow(x, 2) - y * x); 11 } 12 int main() 13 { 14 int T; 15 cin >> T; 16 while(T--){ 17 double x, y; 18 cin >> y; 19 double l = 0, r = 100; 20 double mid; 21 while(r - l > eps){ 22 mid = (l + r)/2; 23 if(f(mid) < y) l = mid; 24 else r = mid; 25 } 26 cout << fixed << setprecision(4) << F(r, y) << endl; 27 } 28 }
原文:http://www.cnblogs.com/NWUACM/p/6442367.html