Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define EQ(a,b) abs((a)-(b))<EPS
using namespace std;
typedef long double D;
const D EPS = 1e-8;

int n,b;
D d;
D p[11],h[11];

bool check(D H, D W){
  D a = -4*H/W/W;
  rep(i,n){
    D x = p[i];
    while(x+EPS>W)x -= W;
    if(EQ(x,0))return false;
    if(a*(x-W/2)*(x-W/2)+H +EPS < h[i])return false;
  }
  return true;
}

int main(){
  cin >> d >> n >> b;
  rep(i,n)cin >> p[i] >> h[i];

  D res = 1e15;
  rep(i,b+1){
    D w = d/(i+1);
    D l = w/4, r = 1e15;
    rep(azu,300){
      D mid = (l+r)/2;
      if(check(mid,w))r = mid;
      else l = mid;
    }
    D vy = sqrt(2*l), vx = w/2/vy;
    res = min(res, sqrt(vy*vy + vx*vx));
  }
  cout << fixed << setprecision(5) << res << endl;
}