Problem: Example

Input

100 100 0 1


Output

1.16699564

Solution (in CPP):

Solution:
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <map>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
    C(){}
};
namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(dot(b,b-c) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}
P unit(const P &p){
    return p/abs(p);
}
P rotate(const P &p, double rad){
    return p *P(cos(rad), sin(rad));
}

bool intersectSS(const L& a, const L& b){
    return ( ccw(a[0],a[1],b[0]) *ccw(a[0],a[1],b[1]) <= 0 ) &&
        ( ccw(b[0],b[1],a[0]) *ccw(b[0],b[1],a[1]) <= 0 );
}
P projection(const L& l, const P& p) {
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}
double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}
VP crosspointCL(const C &c, const L &l){
    VP ret;
    P mid = projection(l, c.p);
    double d = distanceLP(l, c.p);
    if(EQ(d, c.r)){
        ret.push_back(mid);
    }else if(d < c.r){
        double len = sqrt(c.r*c.r -d*d);
        ret.push_back(mid +len*unit(l[1]-l[0]));
        ret.push_back(mid -len*unit(l[1]-l[0]));
    }
    return ret;
}
vector<L> getTangentLine(const C &c, const P &p){
    vector<L> ret;
    P dir = p -c.p;
    if(c.r +EPS < abs(dir)){
        P a = c.p + c.r*unit(dir);
        VP cp = crosspointCL(C(c.p, abs(dir)), L(a, a+dir*P(0,1)));
        for(P cpp: cp){
            ret.push_back(L(p, c.p +c.r*unit(cpp-c.p)));
        }
    }else if(abs(c.r -abs(dir)) < EPS){
        ret.push_back(L(p, p +dir*P(0, 1)));
    }
    return ret;
}
VP getTangentPoint(const C &c, const P &p){
    auto tls = getTangentLine(c, p);
    VP res;
    for(L l: tls){
        res.push_back(projection(l, c.p));
    }
    return res;
}

int main(){
    double x,y,theta,omega;
    cin >> x >> y >> theta >> omega;
    theta *= PI/180;
    omega *= PI/180;
    P s = rotate(P(x, y), -theta);
    double lb=0, ub=1e6;
    for(int rep=0; rep<50; rep++){
        double mid = (lb+ub)/2;
        double r = mid/omega;
        VP tp = getTangentPoint(C(P(0, 0), r), s);
        bool can_escape = tp.empty();
        for(P p: tp){
            if(intersectSS(L(s, p), L(P(0, 0), P(INF, 0)))) continue;
            double arg360 = (arg(p)>0)? arg(p): arg(p)+2*PI;
            double angle = (s.Y > 0)? arg360: 2*PI-arg360;
            if(abs(p-s)/mid < angle/omega){
                can_escape = true;
            }
        }
        if(can_escape){
            ub = mid;
        }else{
            lb = mid;
        }
    }
    cout << fixed << setprecision(10);
    cout << lb << endl;
    return 0;
}