首页 > 其他 > 详细

HDU - 2899 Strange fuction

时间:2017-02-25 18:43:53      阅读:241      评论:0      收藏:0      [点我收藏+]
技术分享
 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 }
View Code

 

HDU - 2899 Strange fuction

原文:http://www.cnblogs.com/NWUACM/p/6442367.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!