EDU88 F. RC Kaboom Show 2900分计算几何之大力出奇迹

//#define LOCAL
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define mem(a, b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define DNF 0x7f
#define DBG printf("this is a input\n")
#define fi first
#define se second
#define mk(a, b) make_pair(a,b)
#define pb push_back
#define p_queue priority_queue
#define CLOSE ios::sync_with_stdio(0); cin.tie(0)

void FileIO()
{
#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("odata.out", "w", stdout);
#endif
}
ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
const int N = 25010;
int n , m;
int x[N] , y[N] , dx[N], dy[N], s[N];
double c[N];
int main(void) {
    scanf("%d",&n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d %d %d %d %d",&x[i], &y[i], &dx[i], &dy[i], &s[i]);
        c[i] = s[i] / sqrt( dx[i]*dx[i] + dy[i]*dy[i]);
    }
    double ans = DBL_MAX;
    for (int i = 1 ; i <= n ; i ++)
    {
        for (int j = i + 1 ; j <= n ; j ++)
        {
            //叉乘
            int cc = dx[j] * dy[i] - dx[i] * dy[j];
            int dey = y[j] - y[i];
            int dex = x[j] - x[i];
            if(cc != 0)
            {
                double t1 = 1.0 * (dx[j] * dey - dy[j] * dex) / (c[i] * cc);
                double t2 = 1.0 * (dx[i] * dey - dy[i] * dex) / (c[j] * cc);
                if(t1 >= 0 && t2 >= 0)
                    ans = min(ans,max(t1,t2));
            }
            else if ((x[i] - x[j]) * dy[j] == (y[i] - y[j]) * dx[j])
            {
                int v = 0;
                if(dex * dx[i] > 0) v += s[i];
                if(dex * dx[j] < 0) v += s[j];
                if(v > 0)
                    ans = min (ans , 1.0 * sqrt(dex*dex+dey*dey) / v);
            }
        }
    }
    if(ans == DBL_MAX)
        printf("No show :(\n");
    else
        printf("%.8lf", ans);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值