Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
bool check(int n, double len, double vx, double vy, vector<double> &p, vector<double> &h) {
  bool ok = true;
  for(int k=0;k<(n);++k) {
    double now = p[k];
    while(now > eps) now -= len;
    now += len;
    ok &= - (now * now / (2 * vx * vx)) + (vy / vx) * now >= h[k];
  }
  return ok;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; double d, b; cin >> d >> n >> b;
  vector<double> p(n), h(n);
  for(int i=0;i<(n);++i) {
    cin >> p[i] >> h[i];
  }
  double ans = INF;
  for(int i=0;i<(b+1);++i) {
    double len = d / (i+1);
    double l = 0, r = INF;
    for(int j=0;j<(500);++j) {
      double vy = (l + r) / 2.0;
      double vx = len / (2 * vy);
      bool ok = check(n, len, vx, vy, p, h);
      if(ok) r = vy;
      else l = vy;
    }
    r = INF;
    for(int j=0;j<(500);++j) {
      double vy1 = (2*l + r) / 3.0;
      double vx1 = len / (2 * vy1);
      double vy2 = (l + 2*r) / 3.0;
      double vx2 = len / (2 * vy2);
      if(vx1 + vy1 < vx2 + vy2) {
        r = vy2;
      } else {
        l = vy1;
      }
    }
    chmin(ans, sqrt(l * l + (len / (2 * l)) * (len / (2 * l))));
  }
  cout << ans << endl;
}