传送门

辣鸡题目毁我人生败我前程

50分代码

//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#define pi acos(-1)
#define eps 1e-9
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
const int N=;
typedef long long LL;
typedef double db;
using namespace std;
int n,cnt[N];
db S; template<typename T>void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} struct pt {
db x,y;
pt(){}
pt(db x,db y):x(x),y(y){}
}p[N],jd[N][]; struct Line {
pt a,b;
Line(){}
Line(pt a,pt b):a(a),b(b){}
}L[N]; int dcmp(db x) { return fabs(x)<=eps?:(x>?:-);}
bool operator == (const pt&A,const pt&B) { return dcmp(A.x-B.x)==&&dcmp(A.y-B.y)==; }
bool operator < (const pt&A,const pt&B) { return dcmp(A.x-B.x)<||(dcmp(A.x-B.x)==&&dcmp(A.y-B.y)<); }
pt operator * (const pt&A,const db&B) { return pt(B*A.x,B*A.y); }
pt operator / (const pt&A,const db&B) { return pt(A.x/B,A.y/B); }
pt operator + (const pt&A,const pt&B) { return pt(A.x+B.x,A.y+B.y); }
pt operator - (const pt&A,const pt&B) { return pt(A.x-B.x,A.y-B.y); }
db cross(pt A,pt B) { return A.x*B.y-A.y*B.x; }
db dot(pt A,pt B) { return A.x*B.x+A.y*B.y; }
db length(pt A) { return dot(A,A); }
db pf(db x) { return x*x; } int ck(pt A,Line li) {
return dcmp(sqrt(length(A-li.a))+sqrt(length(A-li.b))-sqrt(length(li.a-li.b)))==;
} void get_jd(int id,Line li,db r) {
cnt[id]=;
db a=li.a.x,b=li.a.y,c=li.b.x,d=li.b.y;
db e=pf(c-a)+pf(d-b),f=2.0*a*(c-a)+2.0*b*(d-b),g=a*a+b*b-r*r;
db dt=f*f-*e*g;
if(dcmp(dt)<) return;
if(dcmp(dt)==) cnt[id]=;
else cnt[id]=;
db t1=(-f+sqrt(dt))/e/2.0;
db t2=(-f-sqrt(dt))/e/2.0;
jd[id][]=pt(a+t1*(c-a),b+t1*(d-b));
jd[id][]=pt(a+t2*(c-a),b+t2*(d-b));
if(cnt[id]==)
if(!ck(jd[id][],li)) cnt[id]--;
if(!ck(jd[id][],li)) {
cnt[id]--;
if(cnt[id]) jd[id][]=jd[id][];
}
} int ck(db r) {
db rs=;
int jds=,f=;
For(i,,n) {
get_jd(i,L[i],r);
jds+=cnt[i];
if(cnt[i]==) f=;
}
if(jds==&&!f) {
For(i,,n) {
int pr=i==?n:i-;
if(cnt[i]==&&cnt[pr]==) {
pt A=jd[i][],B=jd[pr][],C=p[i];
db a=length(B-C),b=length(A-C),c=length(A-B);
rs=r*r*acos((a+b-c)/(2.0*sqrt(a)*sqrt(b)));
rs+=fabs(cross(A,C));
rs+=fabs(cross(B,C));
break;
}
}
return dcmp(rs-S*2.0)>=;
}
db sum=2.0*pi;
For(i,,n) {
if(cnt[i]==) {
pt A=jd[i][],B=jd[i][];
rs+=fabs(cross(A,B));
db a=length(B),b=length(A),c=length(A-B);
sum-=acos((a+b-c)/(2.0*sqrt(a)*sqrt(b)));
}
}
rs+=r*r*sum;
return dcmp(rs-S*2.0)>=;
} int main() {
#ifdef DEBUG
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
read(n); scanf("%lf",&S);
For(i,,n)
scanf("%lf%lf",&p[i].x,&p[i].y);
p[n+]=p[];
For(i,,n) L[i]=Line(p[i],p[i+]);
db l=,r=1e20;
while(fabs(r-l)>eps) {
db mid=((l+r)/2.0);
if(ck(mid)) r=mid;
else l=mid;
}
printf("%.2lf\n",l);
return ;
}

洛谷P2333 [SCOI2006]一孔之见的更多相关文章

  1. 「 洛谷 」P4539 [SCOI2006]zh_tree

    小兔的话 推荐 小兔的CSDN [SCOI2006]zh_tree 题目限制 内存限制:250.00MB 时间限制:1.00s 标准输入输出 题目知识点 思维 动态规划 \(dp\) 区间\(dp\) ...

  2. 洛谷1640 bzoj1854游戏 匈牙利就是又短又快

    bzoj炸了,靠离线版题目做了两道(过过样例什么的还是轻松的)但是交不了,正巧洛谷有个"大牛分站",就转回洛谷做题了 水题先行,一道傻逼匈牙利 其实本来的思路是搜索然后发现写出来类 ...

  3. 洛谷P1352 codevs1380 没有上司的舞会——S.B.S.

    没有上司的舞会  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond       题目描述 Description Ural大学有N个职员,编号为1~N.他们有 ...

  4. 洛谷P1108 低价购买[DP | LIS方案数]

    题目描述 “低价购买”这条建议是在奶牛股票市场取得成功的一半规则.要想被认为是伟大的投资者,你必须遵循以下的问题建议:“低价购买:再低价购买”.每次你购买一支股票,你必须用低于你上次购买它的价格购买它 ...

  5. 洛谷 P2701 [USACO5.3]巨大的牛棚Big Barn Label:二维数组前缀和 你够了 这次我用DP

    题目背景 (USACO 5.3.4) 题目描述 农夫约翰想要在他的正方形农场上建造一座正方形大牛棚.他讨厌在他的农场中砍树,想找一个能够让他在空旷无树的地方修建牛棚的地方.我们假定,他的农场划分成 N ...

  6. 洛谷P1710 地铁涨价

    P1710 地铁涨价 51通过 339提交 题目提供者洛谷OnlineJudge 标签O2优化云端评测2 难度提高+/省选- 提交  讨论  题解 最新讨论 求教:为什么只有40分 数组大小一定要开够 ...

  7. 洛谷P1371 NOI元丹

    P1371 NOI元丹 71通过 394提交 题目提供者洛谷OnlineJudge 标签云端评测 难度普及/提高- 提交  讨论  题解 最新讨论 我觉得不需要讨论O long long 不够 没有取 ...

  8. 洛谷P1538迎春舞会之数字舞蹈

    题目背景 HNSDFZ的同学们为了庆祝春节,准备排练一场舞会. 题目描述 在越来越讲究合作的时代,人们注意的更多的不是个人物的舞姿,而是集体的排列. 为了配合每年的倒计时,同学们决定排出——“数字舞蹈 ...

  9. 洛谷八月月赛Round1凄惨记

    个人背景: 上午9:30放学,然后因为学校举办读书工程跟同学去书城选书,中午回来开始打比赛,下午又回老家,中间抽出一点时间调代码,回家已经8:50了 也许是7月月赛时“连蒙带骗”AK的太幸运然而因同学 ...

随机推荐

  1. 最大流——hdu4292(类似poj3281 带间隔的流)

    #include<bits/stdc++.h> using namespace std; #define maxn 100005 #define inf 0x3f3f3f3f ]; int ...

  2. tyvj 1194 划分大理石(多重背包)

    传送门 解题思路 二进制优化多重背包裸题. 代码 #include<iostream> #include<cstdio> #include<cstring> #in ...

  3. RPC远程过程调用实例详解

    1.创建IDL文件,定义接口. IDL文件可以由uuidgen.exe创建. 首先找到系统中uuidgen.exe的位置,如:C:\Program Files\Microsoft Visual Stu ...

  4. t检验中的t值和p值是什么关系_t检验和p值的关系

    t检验中的t值和p值是什么关系_t检验和p值的关系 t检验中通过样本均值 总体均值 样本标准差 样本量 可以计算出一个t值,这个t值和p值有什么关系? 根据界值表又会查出一个数,这个数和t值比较,得出 ...

  5. python 中的 用chr()数值转化为字符串,字符转化为数值ord(s)函数

    1.1 python字符串定义 #!/usr/bin/python # -*- coding: utf8 -*- # 定义一个字符串 s1 = 'this is long String that sp ...

  6. 总结windows cmd 查看进程,端口,硬盘信息

    1.查看window所有进程 tasklist 2.查看windows所占用的进程号 tasklist|findstr 1916 3.杀死进程,进程pid taskkill /f /pid 10156 ...

  7. POJ 2954 /// 皮克定理+叉积求三角形面积

    题目大意: 给定三角形的三点坐标 判断在其内部包含多少个整点 题解及讲解 皮克定理 多边形面积s = 其内部整点in + 其边上整点li / 2 - 1 那么求内部整点就是 in = s + 1 - ...

  8. 开发环境、测试环境、生产环境、UAT环境、仿真环境详解

    版权声明:本文为博主原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/WYX15011474269/article ...

  9. iOS开发系列-NSOutputStream

    NSOutputStream 创建一个NSOutputStream实例 - (nullable instancetype)initToFileAtPath:(NSString *)path appen ...

  10. vue倒计时:天时分秒

    data数据定义 data () { return { curStartTime: '2019-07-31 08:00:00', day: '0', hour: '00', min: '00', se ...