Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int d,n,b;
int p[SIZE],h[SIZE];

double calc(int sp){
  double g = 1.0;
  
  double w = (double)d / sp;

  double l = sqrt(sqrt(w*w/4)), r = 1e10;
  
  while(r - l > 1e-9){    
    double vy = (l+r)/2;
    double t = vy / g;
    double vx = w / (t * 2);

    bool flag = true;
    
    for(int i=0;i<n;i++){
      double spp = p[i] - floor(p[i]/w) * w;
      
      if(spp > w/2){
        spp = w - spp;
      }

      if(spp < 1e-11){
        flag = false;
        break;
      }
      
      if(h[i] > vy * spp/vx - g * (spp*spp) / (vx*vx) / 2){
        flag = false;
        break;
      }
    }

    if(flag){
      r = vy;
    }else{
      l = vy;
    }
  }

  double vy = l;
  double t = vy / g;
  double vx = w / (t * 2);

  return sqrt(vx*vx + vy*vy);
}

int main(){

  scanf("%d%d%d",&d,&n,&b);
  
  for(int i=0;i<n;i++)
    scanf("%d%d",p+i,h+i);

  double ans = 1e15;
  
  for(int i=0;i<=b;i++){
    ans = min(ans, calc(i+1));
  }

  printf("%.10lf\n",ans);
  
  return 0;
}