Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

double D;
int N;
int B;
double H[10];
double P[10];
double calc(double base, double len, int idx){
	double h = H[idx];
	double p = P[idx] - base;
	
	double vx = sqrt((len * p - p * p) / (2 * h));
	double vy = len / (2 * vx);
	if(vx > vy){
		return sqrt(len);
	}else{
		return sqrt(vx * vx + vy * vy);
	}

}
int main(){
	cin >> D >> N >> B;
	for(int i = 0; i < N; i++){
		cin >> P[i] >> H[i];
	}
	double ans = 1e9;
	for(int i = 0; i <= B; i++){
		double aa = 0;
		for(int j = 0; j < N; j++){
			for(int k = 0; k <= i; k++){
				if(P[j] < (D / (i + 1)) * (k + 1)){
					aa = max(aa, calc((D / (i + 1)) * k, D / (i + 1), j));
				}
			}
		}
		ans = min(ans, aa);
	}
	printf("%.6lf\n", ans);
}