Problem: Example

Input

100 100 0 1


Output

1.16699564

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;

typedef complex<double> P;

const double EPS = 1e-8;
typedef complex<double> P;

struct Circle {
  P c;
  double r;
  Circle() {}
  Circle(P c, double r) : c(c), r(r) {}
};

double dot  (P a, P b) { return a.real()*b.real() + a.imag()*b.imag(); }
double cross(P a, P b) { return a.real()*b.imag() - a.imag()*b.real(); }

//??????????????????????????\????????????
vector<P> tangent(Circle c, P p){
  vector<P> res;
  double a = abs(p - c.c);
  if(a < c.r - EPS);
  else if(a < c.r + EPS) res.push_back(p);
  else {
    double b = sqrt(a*a-c.r*c.r);
    double psi = arg(p - c.c);
    double phi = M_PI - acos(b/a);
    res.push_back(p + b * P(cos(psi+phi), sin(psi+phi)));
    res.push_back(p + b * P(cos(psi-phi), sin(psi-phi)));
  }
  return res;
}


double pa(double a){
  return M_PI * a / 180.0;
}

double ga(double a){
  return a/M_PI*180.0;
}

double ra(double a){
  if( a < EPS ) return 2.0 * M_PI + a;  
  return a;
}

double sa(double a,double b){
  return a < b ? a+2*M_PI - b : a - b;
}

//w*r = v , r = v/w
bool check( P ps, double v, double s, double w, bool rf){
  Circle c = Circle( P( 0,0 ), v/w );
  vector<P> rp = tangent( c, ps );
  for(int i=0;i<(int)rp.size();i++){
    double a = ra(arg(rp[i])), b = ra(arg(ps)), c = s;
    if( rf ){ 
      if( sa( a, b ) > M_PI ) continue;
      double k = sa( a, c );
      if( abs( ps - rp[i] )/v < k/w ) return true;
    } else {
      if( sa( b, a ) > M_PI ) continue;
      double k = sa( c, a );
      if( abs( ps - rp[i] )/v < k/w ) return true;
    }
  }
  return false;
}


double solve(P ps, double s, double w ){
  double a = ra(arg(ps));
  bool rf = (sa( a, s ) < sa( s, a ));//true:???????¨????false:????¨?
  double st = 0.0, ed = w*abs(ps);  
  for(int i=0;i<100;i++){
    double v = (st + ed)/2.0;
    if( check( ps, v, s, w, rf ) ) ed = v;
    else st = v;
  }
  return st;
}

int main(){
  int x,y,s,w;
  scanf("%d%d%d%d",&x,&y,&s,&w);
  printf("%.9lf\n",solve(P(x,y),pa(s),pa(w)));
}