geometry *2100

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
#define iset indexed_set
#define int long long
#define pi (3.141592653589)
#define mod 1000000007
#define float double
#define ff first
#define ss second
#define mk make_pair
#define pb push_back
#define rep(i, start, end) for (int i = start; i < end; i++)
#define ld long double
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int inf = 1000000000000000000;
using ii = pair<int, int>;
const static int mx = 2e5 + 100;
int sx, sy, tx, ty;
int v, t;
int vx, vy, wx, wy;
bool check(ld val)
{
    ld xx = sx, yy = sy;
    if (val > t)
    {
        xx += t * vx;
        yy += t * vy;
        ld temp = val - t;
        xx += temp * wx;
        yy += temp * wy;
    }
    else
    {
        xx += val * vx;
        yy += val * vy;
    }
    ld dist = (xx - tx) * (xx - tx) + (yy - ty) * (yy - ty);
    dist = sqrtl(dist);
    if (dist <= (ld)(val * v))
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
void solve()
{
    cin >> sx >> sy >> tx >> ty;
    cin >> v >> t;
    cin >> vx >> vy >> wx >> wy;
    ld hi = 1e9, lo = 0, ans = -1, mid;
    while ((hi - lo) > 1e-8)
    {
        mid = (hi + lo) / 2.0;
        if (check(mid))
        {
            ans = mid;
            hi = mid - 1e-8;
        }
        else
        {
            lo = mid + 1e-8;
        }
    }
    cout << fixed << setprecision(8) << ans << "\n";
}
// don't get stuck on a idea
// always write brute force if you cannot think of anything....remember you are anyways not going to
// do anything during the contest
// if constraints are small try to think about dp
// take a deep breathe and think. No hurry.
signed main()
{
    fast
    solve();
    return 0;
}


Comments

Submit
0 Comments
More Questions

214A - System of Equations
287A - IQ Test
1108A - Two distinct points
1064A - Make a triangle
1245C - Constanze's Machine
1005A - Tanya and Stairways
1663F - In Every Generation
1108B - Divisors of Two Integers
1175A - From Hero to Zero
1141A - Game 23
1401B - Ternary Sequence
598A - Tricky Sum
519A - A and B and Chess
725B - Food on the Plane
154B - Colliders
127B - Canvas Frames
107B - Basketball Team
245A - System Administrator
698A - Vacations
1216B - Shooting
368B - Sereja and Suffixes
1665C - Tree Infection
1665D - GCD Guess
29A - Spit Problem
1097B - Petr and a Combination Lock
92A - Chips
1665B - Array Cloning Technique
1665A - GCD vs LCM
118D - Caesar's Legions
1598A - Computer Game