Problem: Example

Input

100 100 0 1


Output

1.16699564

Solution (in CPP):

Solution:
bool debug=false;
#include <stdio.h>
#include <math.h>
double myabs(double x){return x>0?x:-x;}
double min(double a,double b){return a>b?b:a;}
int main(){
	double l,mid,r,ntheta,dis,x,y,ori,theta,speed,runner,sniper;
	scanf("%lf%lf%lf%lf",&x,&y,&theta,&speed);
	dis=sqrt(x*x+y*y);
	if(y==0)ori=0;
	else ori=atan(myabs(y/x))/acos(-1)*180;
	if(x<0)ori=180-ori;
	if(y<0)ori=360-ori;
	if(debug)printf("ori=%lf\n",ori);
	theta=myabs(ori-theta);
	theta=min(360-theta,theta);
	if(debug)printf("%lf\n",theta);
	l=0,r=dis;
	for(int i=0;i<100;i++){
		mid=(l+r)/2;
		runner=sqrt(dis*dis-mid*mid)/(mid*speed/180*acos(-1));
		ntheta=acos(mid/dis)/acos(-1)*180;
		sniper=(ntheta+theta)/speed;
		if(debug)printf("l=%lf r=%lf runner=%lf sniper=%lf ntheta=%lf\n",l,r,runner,sniper,ntheta);
		if(runner<sniper)r=mid;
		else l=mid;
	}
	printf("%.20lf\n",r*speed/180*acos(-1));
}