Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) (int)((a).size())
typedef long long ll;
typedef pair<int,int> PI;

int main(int argc, char *argv[])
{
  int d,n,b;
  cin >> d >> n >> b;
  vector<PI> obj;
  rep(i,n){
    int p,h;
    cin >> p >> h;
    obj.pb(mp(p,h));
  }
  
  double ans = 1e30;

  for(int k = 1; k <= b+1; ++k){
    //if(d%k > 0) continue;
    
    {
      bool ok = 1;
      double haba = d*1./k;
      rep(j,n) ok &= obj[j].F * k % d != 0;
      if(!ok) continue;
    }
    
    
    double low = 0,up = 1e18;
    
    rep(bi_loop,1000){
      double vy = (low+up)/2;
      double vx = d/2./k/vy;
      bool ok = 1;
      double haba = d*1./k;
      
      rep(i,n){
        double x = fmod(obj[i].F, haba);
        double y = -(1./2/vx/vx)*x*x+(vy/vx)*x;
        ok &=  y >= obj[i].S;
      }
      if(!ok){
        low = vy;
        continue;
      }

      up = vy;
    }
    
    //cout << low << " " << up << endl;
    
    double L = d/2./k;
    
    if(L > low*low)
      {
      /*
        vy = sqrt(L);
       */
      double vy = sqrt(L);
      double vx = d/2./k/vy;
      double tans = sqrt(vx*vx+vy*vy);
      ans = min(ans, tans);
    }
    else
      {
      double vy = low;
      double vx = d/2./k/vy;
      double tans = sqrt(vx*vx+vy*vy);      
      ans = min(ans,tans);
    }
  }


  printf("%.18f\n", ans);
  //cout << ans << endl;
  
  return 0;
}