Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define Gene template< class
- #define Rics printer& operator,
- Gene c> struct rge{c b, e;};
- Gene c> rge<c> range(c i, c j){ return {i, j};}
- struct printer{
- ~printer(){cerr<<endl;}
- Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
- Rics(string x){cerr<<x;return *this;}
- Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
- Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
- Gene c >Rics(rge<c> x){
- *this,"["; for(auto it = x.b; it != x.e; ++it)
- *this,(it==x.b?"":", "),*it; return *this,"]";}
- };
- #define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
- #define dbg(x) "[",#x,": ",(x),"] "
- mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
- int my_rand(int l, int r) {
- return uniform_int_distribution<int>(l, r) (rng);
- }
- const double pi = acos(-1);
- const int N = 100000;
- double W_V;
- double theta;
- double f(double r) {
- return sqrt(abs(W_V-1.0/(r*r)));
- }
- double simpson_integration(double a, double b){
- double h = (b - a) / N;
- double s = f(a) + f(b); // a = x_0 and b = x_2n
- for (int i = 1; i <= N - 1; ++i) {
- double x = a + h * i;
- s += f(x) * ((i & 1) ? 4 : 2);
- }
- s *= h / 3;
- return s;
- }
- bool okay(double V, double W, double R) {
- double WR = R*W;
- if(V >= WR) return true;
- W_V = W*W/(V*V);
- double dev = simpson_integration(V/W, R);
- // debug(), dbg(dev);
- return dev <= theta;
- }
- int main() {
- // freopen("in.txt", "r", stdin);
- ios::sync_with_stdio(0);
- cin.tie(0);
- double X, Y;
- cin >> X >> Y;
- double theta0, omega0;
- cin >> theta0 >> omega0;
- if(theta0 > 180) theta0 -= 360;
- theta0 *= pi/180.0;
- double thetaP = atan2(Y, X);
- theta = abs(theta0 - thetaP);
- if(theta > pi) theta = 2*pi - theta;
- double R = sqrt(X*X+Y*Y);
- omega0 *= pi/180.0;
- double lo = 0, hi = 1e7;
- for(int itr = 1; itr <= 60; itr++) {
- double mid = (lo+hi)/2.0;
- if(okay(mid, omega0, R)) hi = mid;
- else lo = mid;
- }
- cout << setprecision(12) << fixed << lo << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement