SHOI2012 信用卡凸包

传送门

顶点凸包+一个圆周长。

#include<bits/stdc++.h>
#define re register
#define cs const
cs int N=4e4+10;
cs double eps=1e-8,oo=1e9,pi=acos(-1);
struct Grid{
	double x,y;
	Grid(double X=0,double Y=0){x=X,y=Y;}
	inline double Angle(){return atan2(y,x);}
	inline double len(){return sqrt(x*x+y*y);}
	friend inline Grid operator +(const Grid &a,const Grid &b){return Grid(a.x+b.x,a.y+b.y);}
	friend inline Grid operator -(const Grid &a,const Grid &b){return Grid(a.x-b.x,a.y-b.y);}
	friend inline Grid operator *(const Grid &a,const double &b){return Grid(a.x*b,a.y*b);}
	friend inline Grid operator /(const Grid &a,const double &b){return Grid(a.x/b,a.y/b);}
	friend inline double dot(const Grid &a,const Grid &b){return a.x*b.x+a.y*b.y;}
	friend inline double cross(const Grid &a,const Grid &b){return a.x*b.y-a.y*b.x;}
	inline Grid rotate(double ang){return Grid(x*cos(ang)-y*sin(ang),x*sin(ang)+y*cos(ang));}
}A[N],S[N];
typedef Grid Point,Vector;
inline int sgn(double x){
	if(x>eps) return 1;
	if(x<-eps) return -1;
	return 0;
}

int n,tot,pos,top;double a,b,r,x,y,angle;
inline void get_pnts(cs Point &O,double ang){
	A[++tot]=Vector( b, a).rotate(ang)+O;
	if(A[0].y>A[tot].y||(A[0].y==A[tot].y&&A[0].x>A[tot].x)) A[0]=A[tot],pos=tot;
	A[++tot]=Vector(-b, a).rotate(ang)+O;
	if(A[0].y>A[tot].y||(A[0].y==A[tot].y&&A[0].x>A[tot].x)) A[0]=A[tot],pos=tot;
	A[++tot]=Vector( b,-a).rotate(ang)+O;
	if(A[0].y>A[tot].y||(A[0].y==A[tot].y&&A[0].x>A[tot].x)) A[0]=A[tot],pos=tot;
	A[++tot]=Vector(-b,-a).rotate(ang)+O;
	if(A[0].y>A[tot].y||(A[0].y==A[tot].y&&A[0].x>A[tot].x)) A[0]=A[tot],pos=tot;
}
inline bool cmp(cs Point &a,cs Point &b){
	double P=atan2(a.y-A[1].y,a.x-A[1].x);
	double Q=atan2(b.y-A[1].y,b.x-A[1].x);
	return (P!=Q)?P<Q:a.x<b.x;
}
inline void Graham(){
	std::swap(A[pos],A[1]),std::sort(A+2,A+tot+1,cmp);
	S[1]=A[1],S[top=2]=A[2];
	for(int re i=3;i<=tot;++i){
		while(top>=3&&(cross(A[i]-S[top-1],S[top]-S[top-1])>=0)) --top;
		S[++top]=A[i];
	}S[top+1]=A[1];
}
double ans=0;
int main(){
	scanf("%d%lf%lf%lf",&n,&a,&b,&r),a-=r*2,b-=r*2,a/=2.0,b/=2.0,A[0]=Point(oo,oo);
	for(int re i=1;i<=n;++i) scanf("%lf%lf%lf",&x,&y,&angle),get_pnts(Point(x,y),angle);
	Graham();
	for(int re i=1;i<=top;++i) ans+=(S[i+1]-S[i]).len();
	printf("%.2lf\n",ans+2.0*pi*r);
}
内容概要:本文详细介绍了手工艺品销售系统的设计与实现,旨在通过计算机技术提升手工艺品销售的信息管理水平。该系统基于Java语言和Spring Boot框架构建,使用MySQL数据库进行数据管理。系统主要功能包括手工艺品管理、评价管理、订单管理、购物车管理和求购管理等,涵盖了管理员、商家和用户三类用户群体的具体操作需求。文中还详细描述了系统的开发技术、设计原则、功能模块、数据库设计及其实现过程,并通过多种测试确保系统的稳定性和功能性。此外,文章讨论了系统的优点,如高效的信息处理、友好的操作界面和较低的误操作率,但也指出了系统在数据存储和代码优化方面存在的不足。 适合人群:对电子商务系统设计感兴趣的计算机专业学生及从业者,特别是那些希望深入了解基于Java和Spring Boot框架的Web应用程序开发的人士。 使用场景及目标:①适用于希望开发或改进手工艺品销售平台的企业和个人;②为学习如何设计和实现高效、易用的电子商务系统提供参考案例;③帮助理解如何利用现代Web开发技术和数据库管理工具提升业务运营效率。 其他说明:尽管系统具备许多优点,但在数据冗余和代码复用性方面仍有改进空间。未来的工作将集中在优化数据库结构和精简代码以提高系统性能和维护性。同时,本文还强调了在项目开发过程中持续学习和解决问题的重要性,感谢了导师和其他相关人员的支持与帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值