AT_abc275_g 题解
Melo.VVちゃん · · 题解
题意等价于求
令
把
然后发现这个
问题可以继续转化为给定一堆向量
本来就存在向量在第三象限显然合法,如果不存在只需要判定是否存在分别处于第二、第四象限的两个向量,满足他俩过第三象限的夹角小于
#include "bits/stdc++.h"
#define f(i ,m ,n ,x) for (int i = (m) ,i##END = (n) ; i <= i##END ; i += (x))
const int N = 2e5 + 25 ;
const double pi = std :: acos (-1.0) ;
int n ; double a[N] ,b[N] ,c[N] ,A[N] ,B[N] ;
int main (void) {
std :: ios :: sync_with_stdio (false) ,
std :: cin.tie (nullptr) ,std :: cout.tie (nullptr) ;
std :: cin >> n ; f (i ,1 ,n ,1)
std :: cin >> a[i] >> b[i] >> c[i] ,a[i] /= c[i] ,b[i] /= c[i] ;
double l = 0.0 ,r = 1e9 ,ans ; f (i ,1 ,55 ,1) {
double mid = (l + r) / 2.0 ;
double theta1 = pi / 2.0 ,theta2 = pi / 2.0 ; bool ok (false) ;
f (i ,1 ,n ,1) {
A[i] = a[i] - mid ,B[i] = b[i] - mid ;
if (A[i] <= 0 && B[i] <= 0) { ok = true ; break ;}
if (A[i] <= 0)
theta1 = std :: min (theta1 ,std :: atan (-B[i] / A[i])) ;
else if (B[i] <= 0)
theta2 = std :: min (theta2 ,std :: atan (-A[i] / B[i])) ;
} if (ok) goto her ;
ok = theta1 + theta2 < pi / 2.0 ; her : ;
if (ok) r = ans = mid ; else l = mid ;
} std :: cout << std :: fixed <<
std :: setprecision (6) << 1.0 / ans << '\n' ;
return 0 ;
}