Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include <cmath>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
int d, n, b, p[15], h[15];
int main() {
	cin >> d >> n >> b;
	for (int i = 0; i < n; i++) cin >> p[i] >> h[i];
	double ret = 1.0e+30;
	for (int i = 1; i <= b + 1; i++) {
		bool flag = true;
		for (int j = 0; j < n; j++) {
			if (p[j] * i % d == 0) flag = false;
		}
		if (!flag) continue;
		double u = 1.0 * d / i, z = 0.0;
		for (int j = 0; j < n; j++) {
			double pos = fmod(1.0 * p[j], u);
			double x = abs(pos - 0.5 * u) / (0.5 * u);
			double h2 = h[j] / (1 - x * x);
			z = max(z, h2);
		}
		z = max(z, u / 4.0);
		double v = sqrt(2 * z + u * u / 8.0 * (1.0 / z));
		ret = min(ret, v);
	}
	cout << fixed << setprecision(15) << ret << endl;
	return 0;
}