Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int d,n,b;
double pt;
const int maxn = 110;
double x[maxn],y[maxn];

int main()
{
	scanf("%d%d%d",&d,&n,&b);
	double ftd = d, ftb = b,ftn = n;
	for (int i=1; i<=n; ++i)
	{
		int tx, ty;
		scanf("%d%d",&tx,&ty);
		x[i] = tx;y[i] = ty;
	}
	double ansv = 100000000000000;
	for (int i=b; i>=0; --i)
	{
		//printf("%d\n",i);
		int tag = 0;
		double fnh = 0;
		double aniv = ansv;
		ftn = i+1;
		pt = ftd/((double)i+1);
		double dpt = 0;
		double nh = 0;
		for (int j=1; j<=n; ++j)
		{
			double ftx = x[j],fty = y[j];
			while (true)
			{
				if (ftx-pt<0) break;
				else
				ftx-=pt;
			}
		//	printf("%.6f\n",ftx);
			if (ftx == 0) 
			{
				tag = 1;break;
			} 
		//	printf("%.5f\n",ftx);
			fnh =-( fty * ftd * ftd/(ftx * (ftx-ftd/ftn) * 4 * ftn*ftn));
		//	printf("%.5f\n",fnh);
			if (fnh>nh) nh = fnh;
		}
	//	if (!tag)
		//	printf("%.5f\n",aniv);
		if (!tag)
		{
			double av;
			double stdh = ftd/(4*(i+1));
		//	printf("%.5f %.5f\n",nh,stdh);
			if (nh<stdh)
			{
				nh = stdh;
				av = sqrt(2*nh+ftd*ftd/(8*nh*ftn*ftn));
			//	av = sqrt(ftd/(i+1));
			}
			else
				av = sqrt(2*nh+ftd*ftd/(8*nh*ftn*ftn));
			if (av<ansv) ansv = av;
		}
	}
	printf("%.5f",ansv);
	return 0;
}