hiho week 40 register

Ended

Participants:1627

Verdict:Accepted
Score:100 / 100
Submitted:2015-04-04 23:47:53

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <cstdio>
#include <cmath>
#define eps 0.00000001
double a,b,c,x,y;
double getf(double x0){
double t=a*x0*x0+b*x0+c;
return sqrt((x-x0)*(x-x0)+(y-t)*(y-t));}
int main(){
scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&x,&y);
double l=-200,h=200;
while(h-l>=eps){
double lm=(l+h)/2,rm=(lm+h)/2;
if(getf(lm)>getf(rm)) l=lm;else h=rm;}
printf("%.3lf\n",getf(l));return 0;}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX