Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include <iostream>
#include <cstdio>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
double d,p[10],h[10];
int n,b;
double u;
bool allok(double m){
	rep(i,n){
		double x=p[i];
		while(x>u) x-=u;
		if((4.0*m/u/u)*(-x*x+u*x)<h[i]) return false;
	}
	return true;
}
int main(){
	cin>>d>>n>>b;
	rep(i,n) cin>>p[i]>>h[i];
	double ans=1e100;
	rep(bounce,b+1){
		u=d/(bounce+1);
		double ub=1e10,lb=u/4;
		rep(tt,200){
			double m=(ub+lb)/2;
			if(allok(m)) ub=m;
			else lb=m;
		}
		double vy=sqrt(2.0*ub),vx=u/2.0/vy;
		ans=min(ans,sqrt(vx*vx+vy*vy));
	}
	printf("%.12f\n",ans);
}