题意:求多边形的核的面积。

敲一下半平面交模板........  然后我wa了一早上就因为写了%lf  不知道poj什么破机制还不能用lf的,真的想跳楼

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define MN 50000
#define eps 1e-10
using namespace std;
inline int read()
{
int x = , f = ; char ch = getchar();
while(ch < '' || ch > ''){ if(ch == '-') f = -; ch = getchar();}
while(ch >= '' && ch <= ''){x = x * + ch - '';ch = getchar();}
return x * f;
} struct P{
double x,y;
P(double _x=,double _y=):x(_x),y(_y){}
P operator + (P b) {return P(x+b.x,y+b.y);}
P operator - (P b) {return P(x-b.x,y-b.y);}
P operator * (double b) {return P(x*b,y*b);}
friend double cross(P a,P b) {return a.x*b.y-b.x*a.y;}
}p[MN+],pt[MN+]; struct L{
P p,v;double slop;
L(){}
L(P x,P y):p(x),v(y){slop=atan2(y.y,y.x);}
P operator * (L b){P a=p-b.p;double t=cross(b.v,a)/cross(v,b.v);return p+v*t;}
bool left(P b){ return cross(v,b-p)>eps;}
bool operator < (const L &y) const {return slop<y.slop;}
}s[MN+],q[MN+]; int n,top,tail; void solve()
{
q[top=tail=]=s[];
for(int i=;i<=n;i++)
{
while(top>tail&&!s[i].left(p[top])) --top;
while(top>tail&&!s[i].left(p[tail+])) ++tail;
if(fabs(s[i].slop-q[top].slop)<eps)
q[top]=s[i].left(q[top].p)?q[top]:s[i];
else q[++top]=s[i];
p[top]=q[top]*q[top-];
}
while(tail<top&&(q[tail].left(p[top])==)) --top;
} int main()
{
for(int T=read();T;T--)
{
n=read();
for(int i=;i<=n;i++) scanf("%lf%lf",&pt[i].x,&pt[i].y);
for(int i=;i<=n;i++) s[i]=L(pt[i-],pt[i]-pt[i-]);
s[]=L(pt[n],pt[]-pt[n]);
sort(s+,s+n+); solve();
if(top-tail+<)
{
for(int i=;i<n;i++) s[i]=L(pt[i+],pt[i]-pt[i+]);
s[n]=L(pt[],pt[n]-pt[]);
sort(s+,s+n+);solve();
}
if(top-tail+<) puts("0.00");
else
{
p[tail]=q[tail]*q[top];double area=;
for(int i=tail;i<top;i++) area+=cross(p[i],p[i+]);
area+=cross(p[top],p[tail]);
printf("%.2f\n",fabs(area)/2.00+eps);
}
}
return ;
}

最新文章

  1. Bash 中的环境变量
  2. mysql workbench is well-designed
  3. ServiceStack.Redis 使用教程
  4. 查看Linux下*.a库文件中文件、函数、变量等情况
  5. 一款基于css3的3D图片翻页切换特效
  6. 【Java Web】Eclipse中配置Marven环境
  7. aaalogo写入中文出错的解决方法
  8. PHP随机生成指定时间段的指定个数时间
  9. PAT 团体程序设计天梯赛-练习集 L1-016. 查验身份证
  10. Maven第一篇【介绍、安装、结构目录】
  11. Oracle-表被锁住
  12. java学习——java按值传递和按址传递
  13. Windows编译OpenCV4Android解决undefined reference to std错误
  14. css 通配符选择器
  15. ERP口碑订单无法落桌的解决方法
  16. P2257 YY的GCD--洛谷luogu
  17. Flutter路由跳转及参数传递
  18. TP5.1 钩子与行为应用
  19. BOM (字节顺序标记)
  20. java 之多线程

热门文章

  1. Scrum 冲刺 第二日
  2. vue 中获取select 的option的value 直接click?
  3. HTML事件处理程序
  4. Python内置函数(33)——any
  5. 新概念英语(1-95)Tickets,please!
  6. Spring中获取request的几种方法,及其线程安全性分析
  7. 使用Java High Level REST Client操作elasticsearch
  8. Python学习之条件判断和循环
  9. Intent 的两种主要使用方法
  10. django Form组件 上传文件