Problem: Example

Input

100 100 0 1


Output

1.16699564

Solution (in CPP):

Solution:
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double PI=acos(-1.0);
double EPS=1e-9;
double th;
double p;
double o;
double calc(double r,double a,double v){
	double x=o-(r*cos(a));
	double y=r*sin(a);
	double t=sqrt(x*x+y*y)/v;
	double s=(th+a)/p;
	return t-s;
}
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	double x=sqrt(a*a+b*b);
	o=x;
	th=atan2(b,a)-c*PI/180;
	while(th<-EPS)th+=PI*2;
	while(th>2*PI+EPS)th-=PI*2;
	if(th>PI)th=PI*2-th;
	double left=0;
	double right=10000;
	double v=PI*d/180;
	p=v;
	//printf("%f\n",th);
	for(int i=0;i<100;i++){
		double M=(left+right)/2;
		double r=M/v;
		
		if(r>=x){
			right=M;continue;
		}
		double L=0;
		double R=PI/2-asin(r/x);
		bool ok=false;
		for(int j=0;j<100;j++){
			double m1=(L*2+R)/3;
			double m2=(L+R*2)/3;
			double t1=calc(r,m1,M);
			double t2=calc(r,m2,M);
			if(t1<0)ok=true;
			if(t2<0)ok=true;
			if(t1<t2)R=m2;
			else L=m1;
		}
	//	printf("%f %f %f %f\n",M,r,x,L);
		if(ok)right=M;
		else left=M;
	}
	printf("%.12f\n",left);
}