这一次我们就简单一点了,题目在此:
2.437
//三分极值
#include<cstdio>
#include<algorithm>
#include<cmath>
//#include<bits/stdc++.h>
using namespace std;
template<class T>inline T read(T&x)
{
    char c;
    while((c=getchar())<=32)if(c==EOF)return 0;
    bool ok=false;
    if(c=='-')ok=true,c=getchar();
    for(x=0; c>32; c=getchar())
        x=x*10+c-'0';
    if(ok)x=-x;
    return 1;
}
template<class T> inline T read_(T&x,T&y)
{
    return read(x)&&read(y);
}
template<class T> inline T read__(T&x,T&y,T&z)
{
    return read(x)&&read(y)&&read(z);
}
template<class T> inline void write(T x)
{
    if(x<0)putchar('-'),x=-x;
    if(x<10)putchar(x+'0');
    else write(x/10),putchar(x%10+'0');
}
template<class T>inline void writeln(T x)
{
    write(x);
    putchar('\n');
}
//-------ZCC IO template------
const int maxn=1000011;
const double inf=999999999;
#define lson (rt<<1),L,M
#define rson (rt<<1|1),M+1,R
#define M ((L+R)>>1)
#define For(i,t,n) for(int i=(t);i<(n);i++)
typedef long long  LL;
typedef double DB;
typedef pair<int,int> P;
#define bug printf("---\n");
#define mod 10007
double px,py;
double a,b,c;
double d(double x)
{
    return sqrt((x-px)*(x-px)+(a*x*x+b*x+c-py)*(a*x*x+b*x+c-py));
}
DB ts(double left,double right)
{
    DB lm,rm,dis;
    DB y1=0,y2=0;
    while(left<=right)
    {
        dis=(right-left)/3.0;
        lm=left+dis;
        rm=lm+dis;
        y1=d(lm),y2=d(rm);
        //printf("%lf   %lf\n",left,right);
        //getchar();
        if(y1==y2)return y1;
        else if(y1<y2)
        {
            right=rm;
        }
        else
        {
            left=lm;
        }
    }
    return min(y1,y2);
}
//0.421
int main()
{
    //#ifndef ONLINE_JUDGE
    // freopen("in.txt","r",stdin);
    //#endif // ONLINE_JUDGE
    int n,m,i,j,t;
    while(~scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&px,&py))
    {
        if(d(px)==py)
            printf("%0.00\n");
        else
            printf("%.3lf\n",ts(-200,200));
    }
    return 0;
}
原文:http://blog.csdn.net/u013167299/article/details/45033715