题意

题目链接

Sol

欲哭无泪啊qwq。。。。昨晚一定是智息了qwq

说一个和标算不一样做法吧。。

显然\(x\)轴是可以三分的,半径是可以二分的。

恭喜你获得了一个TLE的做法。。

然后第二维的二分是没有必要的,直接拿圆的标准方程推一下取个最大值就行了。。。。。昨晚没想到qwq给数学老师丢脸了。。

#include<cstdio>
#include<cmath>
#include<algorithm>
#define double long double
using namespace std;
const double eps = 1e-7, INF = 1e18;
const int MAXN = 1e5 + 10;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0',c = getchar();
return x * f;
}
int N, up, down;
double max(double a, double b) {return a > b ? a : b;}
double min(double a, double b) {return a < b ? a : b;}
struct Node {
double x, y;
}a[MAXN];
int check(int x, int y) {
if(x < 0 && y > 0) return 1;
else return 0;
}
double mxr;
double sqr(double x) {
return x * x;
}
double f(double x) {
double mx = 0;
for(int i = 1; i <= N; i++)
mx = max(mx, fabs((sqr(a[i].x - x) + sqr(a[i].y)) / (2.0 * a[i].y)));
return mx;
} int main() {
N = read();
double L = INF, R = -INF;
for(int i = 1; i <= N; i++) {
a[i].x = read(), a[i].y = read();
up = min(up, a[i].y);
mxr = max(a[i].y, mxr);
L = min(a[i].x, L);
R = max(a[i].x, R);
}
if(check(up, mxr)) {puts("-1"); return 0;}
mxr = INF;
if(up < 0) for(int i = 1; i <= N; i++) a[i].y = -a[i].y;
int tim = 100;
while(tim--) {
double x = (2 * L + R) / 3, y = (L + 2 * R) / 3;
f(x) < f(y) ? R = y : L = x;
// printf("%Lf %Lf\n", f(x), f(y));
}
printf("%.10Lf", f(L));
return 0;
}

cf1059D. Nature Reserve(三分)的更多相关文章

  1. CF1059D Nature Reserve

    原题链接 网络不好的可以到洛谷上去QwQ 题目大意 有N个点,求与y=0相切的,包含这N个点的最小圆的半径 输入输出样例 输入: 2 0 1 1 1 输出 0.625 感觉最多是蓝题难度? 首先无解的 ...

  2. CF1059D Nature Reserve(二分)

    简洁翻译: 有N个点,求与y=0相切的,包含这N个点的最小圆的半径 题解 二分半径右端点开小了结果交了二十几次都没A……mmp…… 考虑一下,显然这个半径是可以二分的 再考虑一下,如果所有点都在y轴同 ...

  3. Codeforces Round #514 (Div. 2):D. Nature Reserve(二分+数学)

    D. Nature Reserve 题目链接:https://codeforces.com/contest/1059/problem/D 题意: 在二维坐标平面上给出n个数的点,现在要求一个圆,能够容 ...

  4. E - Nature Reserve CodeForces - 1059D

    传送门 There is a forest that we model as a plane and live nn rare animals. Animal number iihas its lai ...

  5. Nature Reserve

    Nature Reserve time limit per test:2 seconds memory limit per test:256 megabytes input:standard inpu ...

  6. [CodeForces]1059D Nature Reserve

    大意:给你一个平面上N(N<=100000)个点,问相切于x轴的圆,将所有的点都覆盖的最小半径是多少. 计算几何???Div2的D题就考计算几何???某人昨天上课才和我们说这种计算几何题看见就溜 ...

  7. D - Nature Reserve(cf514,div2)

    题意:给出n(n<=1e5)个点,求一个最小的圆,与x轴相切,并且包含这n个点 思路:我第一想到的是,这个圆一定会经过一个点,再根据与x轴相切,我们可以找到最小的圆,让它包含其余的点,但是如何判 ...

  8. Codeforces Round #514 (Div. 2) D. Nature Reserve

    http://codeforces.com/contest/1059/problem/D 最大值: 最左下方和最右下方分别有一个点 r^2 - (r-1)^2 = (10^7)^2 maxr<0 ...

  9. [ CodeForces 1059 D ] Nature Reserve

    \(\\\) \(Description\) 你现在有\(N\)个分布在二维平面上的整点\((x_i,y_i)\),现在需要你找到一个圆,满足: 能够覆盖所有的给出点 与\(x\)轴相切 现在需要你确 ...

随机推荐

  1. Common operators to overload-c++运算符重载的标准语法(全)

    Common operators to overload Most of the work in overloading operators is boiler-plate code. That is ...

  2. sklearn.metrics.roc_curve使用说明

    roc曲线是机器学习中十分重要的一种学习器评估准则,在sklearn中有完整的实现,api函数为sklearn.metrics.roc_curve(params)函数. 官方接口说明:http://s ...

  3. Js 向json对象中添加新元素

    即:var json={a:1,b:2} json.c=3  添加新元素直接使用赋值就行了

  4. HDU-Big Number (斯特林公式)

    In many applications very large integers numbers are required. Some of these applications are using ...

  5. 75th LeetCode Weekly Contest All Paths From Source to Target

    Given a directed, acyclic graph of N nodes.  Find all possible paths from node 0 to node N-1, and re ...

  6. HDU1085 Holding Bin-Laden Captive!

    Description We all know that Bin-Laden is a notorious terrorist, and he has disappeared for a long t ...

  7. echarts和highcharts

    highcharts是基于svg技术的 echarts基于canvas 后者可以在浏览器中实现3D图形  链接  ,这种效果highcharts是完全不可能做得到的.

  8. oracle Clob类型转换成String类型

    转载:https://www.cnblogs.com/itmyhome/p/4131339.html Clob类型转换成String类型 oracle中表结构如下: create table GRID ...

  9. eclipse 离线安装STS插件

    1.下载 eclipse Version: 2018-12 (4.10.0) 下载sts相应版本:https://spring.io/tools3/sts/all 2.安装 Help->Inst ...

  10. ASC19超算概述

    初赛题目组成 设计超算集群(看参考文献做设计) 对超算集群进行性能测试(一般来讲的测试工具就是用HPL,找到最适合的参数,达到最优秀的计算能力) 数字图像处理(通常代码量较大,代码优化较为困难,优化偏 ...