Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
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 M=(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(M*M*now/c-M*M*now*now/c/c/2<h[j])
				{
					flag=0;
					break;
				}
			}
			(flag?R:L)=M;
		}
		double vy=max(R,sqrt(c));
		ans=min(ans,hypot(c/vy,vy));
	}
	cout<<fixed<<setprecision(9)<<ans<<endl;
}