### hdu2899 Strange fuction（二分兼三分）

`#include <stdio.h>#include <algorithm>#include <string.h>#include <cmath>#include <iostream>#include <stdlib.h>using namespace std;const int N = 100;const int INF = 1000000;double ans(double x,double y){    return 6*pow(x,7)+8*pow(x,6)+7*pow(x,3)+5*x*x-y*x;}double der(double x,double y){    return 42*pow(x,6)+48*pow(x,5)+21*pow(x,2)+10*x-y;}int main(){   // freopen("in.txt", "r", stdin);    int T;    double r, l, mid, y;    scanf("%d", &T);    while(T --)    {        scanf("%lf", &y);        r = 100;        l = 0;        while(fabs(r - l) > 1e-10)        {            mid = (r + l) / 2.0;//注意這里是+號，還有2.0            if(der(mid, y) > 0) r = mid;            else l = mid;        }        printf("%.4lf\n", ans(mid, y));    }    return 0;}`

`#include <stdio.h>#include <algorithm>#include <string.h>#include <cmath>#include <iostream>#include <stdlib.h>using namespace std;const int N = 100;const int INF = 1000000;double ans(double x,double y){    return 6*pow(x,7)+8*pow(x,6)+7*pow(x,3)+5*x*x-y*x;}int main(){   // freopen("in.txt", "r", stdin);    int T;    double r, l, mid, y, midmid;    scanf("%d", &T);    while(T --)    {        scanf("%lf", &y);        r = 100;        l = 0;        while(fabs(r - l) > 1e-10)        {            mid = (r + l) / 2.0;            midmid = (mid + r) / 2.0;            if(ans(midmid, y) < ans(mid, y)) l = mid;            else r = midmid;        }        printf("%.4lf\n", ans(l, y));    }    return 0;}`