Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;


double EPS=0.000000001;
vector<double> p(10),h(10);
double d,n,b;


bool check(double v,int k){
    for (int i = 0; i < n; i++) {
        double x=p[i]-floor(p[i]/(d/k))*(d/k);
        double y=2*k*v*v*x/d*(1-k*x/d);
        if(y<EPS) return false;
        if(y<=h[i]) return false;
    }
    return true;
}

int main(){
    cin >> d >> n >> b;
    for (int i = 0; i < n; i++) {
        cin >> p[i] >> h[i];
    }
    double ans=1e9;
    for (int k = 1; k <= b+1; k++) {
        double l=0.0,r=1e9;
        while(abs(r-l)>EPS){
            double m=(l+r)/2;
            if(check(m,k)) r=m;
            else l=m;
        }
        double v=sqrt(d/(2*k));
        if(r>v) ans=min(ans,sqrt((d/(2*k*r)+r)*(d/(2*k*r)+r)-d/k));
        else ans=min(ans,v*sqrt(2));
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}