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<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int n,b;
double d,p[10],h[10];
int main()
{
  cin>>d>>n>>b;
  for(int i=0;i<n;i++)cin>>p[i]>>h[i];
  double ans=1e300;
  for(int i=0;i<=b;i++)
  {
    double c=d/2/(i+1);
    double L=1e-15,R=1e15;
    for(int cnt=0;cnt<100;cnt++)
    {
      double vy=(L+R)/2;
      bool flag=1;
      for(int j=0;j<n;j++)
      {
        double now=p[j];
        while(now>=c*2)now-=c*2;
        if(now*vy*vy/c-now*now*vy*vy/2/c/c<h[j])
        {
          flag=0;
          break;
        }
      }
      (flag?R:L)=vy;
    }
    double vy=max(R,sqrt(c));
    ans=min(ans,hypot(vy,c/vy));
  }
  cout<<fixed<<setprecision(9)<<ans<<endl;
}