Problem: Example

Input

100 100 0 1


Output

1.16699564

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 300005
#define int int64_t

const double pi = acos(-1);

int32_t main(){
//	cout << atan2(1,1) << '\n';
//	cout << atan2(1,-1) << '\n';
//	cout << atan2(-1,-1) << '\n';
//	cout << atan2(-1,1) << '\n';
	//return 0;
	IOS;
	double x,y,t,o;
	cin >> x >> y >> t >> o;
	t = t*pi/180;
	o = o*pi/180;
	double l,r,d = hypot(x,y),orit = atan2(y,x);
	if(orit < 0) orit += 2*pi;
	double d1 = t - orit;
	if(d1 < 0) d1 += 2*pi;
	double d2 = orit - t;
	if(d2 < 0) d2 += 2*pi;
	l = 0, r = d;
	for(int i=0;i<100;i++){
		double m = (l+r) * 0.5;
		double deg2 = acos(m/d);
		double tmp = (d1<d2)?(t-(orit - deg2)):(orit+deg2-t);
		if(tmp > 2*pi) tmp -= 2*pi;
		if(tmp < 0) tmp += 2*pi;
		double tt = tmp/o; 
		double v1 = sqrt(d*d-m*m)/tt;
		double v2 = o*m;
		if(v1 < v2) r = m;
		else l = m;
	}
	double m = (l+r) * 0.5;
	double deg2 = acos(m/d);
	double tmp = orit + deg2 - t;
	if(tmp < 0) tmp += 2*pi;
	double tt = tmp/o;
	double v1 = sqrt(d*d-m*m)/tt;
	double v2 = o*m;
	cout << fixed << setprecision(12) << v2 << '\n';
	return 0;
}