Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define REP(i, n) rep(i, 0, n)
using namespace std;

const double PI = acos(-1);
const double EPS = 1e-10;
int d, n, b;
int p[10], h[10];

bool check(double theta, double L) {
    double v = sqrt(L / sin(2 * theta));
    double vx = v * cos(theta);
    double vy = v * sin(theta);
    REP(i, n) {
        double x = fmod(p[i], L);
        double y = vy * x / vx - x * x / (2 * vx * vx);
        if (y + EPS < h[i]) return false;
    }
    return true;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);

    cin >> d >> n >> b;
    REP(i, n) cin >> p[i] >> h[i];
    double ans = 1e9;
    REP(k, b + 1) {
        double L = 1.0 * d / (k + 1);
        double ng = PI / 4, ok = PI / 2;
        REP(i, 100) {
            double m = (ng + ok) / 2;
            if (check(m, L)) ok = m;
            else ng = m;
        }
        ans = min(ans, sqrt(L / sin(2 * ok)));
    }
    cout << ans << endl;
}