Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
// ACM-ICPCアジア地区予選2014 D. Space Golf

#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>

using namespace std;

double getMinYvel(const vector<int>& p, const vector<int>& h, double jumpX){
	double L = 0, R = 1e12;
	for(int _=0;_<200;_++){
		double v = 0.5*(L+R);
		bool ok = true;
		for(int i=0;i<p.size();i++){
			int block = p[i]/jumpX;
			double t = 2.0*(p[i]-block*jumpX)/jumpX*v;
			if(h[i] > t*(v-0.5*t)){
				ok = false;
				break;
			}
		}
		if(ok) R = v;
		else   L = v;
	}
	return 0.5*(L+R);
}

int main(){
	int d, n, b;
	while(cin >> d >> n >> b){
		vector<int> p(n), h(n);
		for(int i=0;i<n;i++) cin >> p[i] >> h[i];
		double res = 1e12;
		for(int div=1;div<=b+1;div++){
			double jumpX = (double)d/div;
			double L = getMinYvel(p, h, jumpX), R = 1e12;
			for(int _=0;_<200;_++){
				double vy1 = (2*L+R)/3, vy2 = (L+2*R)/3;
				double vx1 = 0.5*jumpX/vy1, vx2 = 0.5*jumpX/vy2;
				if(vx1*vx1+vy1*vy1 < vx2*vx2+vy2*vy2) R = vy2;
				else L = vy1;
			}
			double velY = 0.5*(L+R);
			double velX = 0.5*jumpX/velY;
			res = min(res, sqrt(velX*velX+velY*velY));
		}
		printf("%.6lf\n", res);
	}
}