Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

typedef pair<double, double> PDD;

const double EPS = 1e-8;
const double PI = acos(-1.0);

int D, N, B;
vector<PDD> os;

double get_v0(double th, int bound)
{
	double d = D/(bound+1.0);
	return sqrt(d/sin(2*th));
}

double get_h(double x, double v0, double th)
{
	double vx = v0*cos(th), vy = v0*sin(th);
	return -(x*x/(2.0*vx*vx))+ (vy/vx)*x;
}

bool check(double th, double bound)
{
	double end = D/(bound+1.0);
	double v0 = get_v0(th, bound);
	
	rep(i, N) {
		double obx = os[i].first;
		while (obx - EPS > end) obx -= end;
		if (get_h(obx, v0, th) + EPS < os[i].second)
			return false;
	}
	
	return true;
}

int main()
{
	cin>>D>>N>>B;
	os.resize(N);
	rep(i, N) {
		cin>>os[i].first>>os[i].second;
	}
	
	double ans = INF;
	for (int b=0; b<=B; b++) {
		double lb = PI/4, ub = PI/2;
		for (int i=0; i<100; i++) {
			double mid = (lb+ub)/2;
			
			if (check(mid, b)) {
				ub = mid;
			} else {
				lb = mid;
			}
		}
		
		ans = min(ans, get_v0(lb, b));
	}
	
	cout << fixed << setprecision(8);
	cout << ans << endl;
}