Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include <stdio.h>
#include <math.h>
#define MAX 20

double d;
int n, b;
struct data{
	double hi, li;
};
data targ[MAX];

double go(double D){
	int i, j;
	data t[MAX];
	double vx=100000000.0, vy;
	for (i=1;i<=n;i++){
		t[i]=targ[i];
		for (;;){
			if (t[i].li<=D) break;
			t[i].li-=D;
		}
		double k;
		k=D*t[i].li-t[i].li*t[i].li;
		k/=(2.0*t[i].hi);
		if (vx>sqrt(k)) vx=sqrt(k);
	}

	if (vx>sqrt(D/2)) return sqrt(D);
	else{
		vy=D/(2*vx);
		return sqrt(vx*vx+vy*vy);
	}
}

int main(void){
	int i;
	double ret, ans=10000000000.0;
	scanf("%lf %d %d", &d, &n, &b);
	for (i=1;i<=n;i++) scanf("%lf %lf", &targ[i].li, &targ[i].hi);
	for (i=0;i<=b;i++){
		ret=go(d/(double)(i+1));
		if (ret<ans) ans=ret;
	}
	printf("%.6lf\n", ans);
	return false;
}