博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
●POJ 2187 Beauty Contest
阅读量:4553 次
发布时间:2019-06-08

本文共 1486 字,大约阅读时间需要 4 分钟。

 

题链:

题解:

计算几何,凸包,旋转卡壳

一个求凸包直径的裸题,旋转卡壳入门用的。

代码:

#include
#include
#include
#include
#include
#define MAXN 50050using namespace std;const double eps=1e-8;int sign(double x){ if(fabs(x)<=eps) return 0; return x<0?-1:1;}struct Point{ double x,y; Point(double _x=0,double _y=0):x(_x),y(_y){} void Read(){scanf("%lf%lf",&x,&y);}};typedef Point Vector;bool operator < (Point A,Point B){return sign(A.x-B.x)<0||(sign(A.x-B.x)==0&&sign(A.y-B.y)<0);}bool operator == (Point A,Point B){return sign(A.x-B.x)==0&&sign(A.y-B.y)==0;}Vector operator - (Point A,Point B){return Vector(A.x-B.x,A.y-B.y);}double operator ^ (Vector A,Vector B){return A.x*B.y-A.y*B.x;}double operator * (Vector A,Vector B){return A.x*B.x+A.y*B.y;}Point D[MAXN],C[MAXN];double GL2(Vector A){//Get_Length^2 return A*A;}double DA(Point P,Point P1,Point P2){//Directed_Area return (P-P1)^(P-P2);}int Andrew(int dnt){ int cnt=0,k; sort(D,D+dnt); dnt=unique(D,D+dnt)-D; for(int i=0;i
1&&sign((C[cnt-1]-C[cnt-2])^(D[i]-C[cnt-2]))<=0) cnt--; C[cnt++]=D[i]; } k=cnt; for(int i=dnt-2;i>=0;i--){ while(cnt>k&&sign((C[cnt-1]-C[cnt-2])^(D[i]-C[cnt-2]))<=0) cnt--; C[cnt++]=D[i]; } return cnt-(dnt>1?1:0);}double RC_GD(int hnt){//Rotating_Calipers_Get_Diameter if(hnt==1) return 0; if(hnt==2) return GL2(C[1]-C[0]); double Di=0; int j=0; C[hnt]=C[0]; for(int i=0;i

  

转载于:https://www.cnblogs.com/zj75211/p/8227652.html

你可能感兴趣的文章
ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path
查看>>
log4net 自定义日志级别记录多个日志
查看>>
imx6 system boot
查看>>
iOS .pch文件的使用
查看>>
idea 设置黑色背景
查看>>
poj1014 Dividing (多重背包)
查看>>
ArcEngine下一个TIN生成的轮廓
查看>>
波折yosemite下载过程
查看>>
Oracle Hints具体解释
查看>>
数据流图的画法
查看>>
spring中配置了事务,数据业务层捕获异常,事务配置不成功?
查看>>
c++,兴之所向,学后有感
查看>>
[剑指offer] 32. 把数组排成最小的数
查看>>
十六. 赋值与取值 OGNL 第4章. 表达式
查看>>
小规模纳税人和一般纳税人的区别
查看>>
揭秘地产大腕们的发家史
查看>>
QDUOJ 一道简单的数据结构题 栈的使用(括号配对)
查看>>
python中matplotlib.pyplot中cm的属性
查看>>
HDU 3622 Bomb Game 二分+2-SAT
查看>>
关于在读取excel的文件时候,放在服务器上就报路径错误
查看>>