hdu1392——凸包模板
来源:互联网 发布:javascript对象转json 编辑:程序博客网 时间:2024/05/18 01:40
http://acm.hdu.edu.cn/showproblem.php?pid=1392
type point=record x,y:longint; end;var s,p:array[1..200]of point; n,l,i,min,i1,x1,tot:longint; x,y:array[1..200]of longint; p0:point; ans:real; {operator -(a,b:point)c:point;begin c.x:=a.x-b.x; c.y:=a.y-b.y;end;operator *(a,b:point)c:longint;begin c:=a.x*b.y-a.y*b.x;end; }function f(a,b,c:point):longint;var u1,u2,v1,v2:longint;begin u1:=a.x-c.x; v1:=a.y-c.y; u2:=b.x-c.x; v2:=b.y-c.y; f:=u1*v2-u2*v1;end;procedure qsort(l,r:longint;p0:point);var i,j:longint; mid,t:point;begin i:=l;j:=r; mid:=p[(l+r) div 2]; repeat while f(p[i],mid,p0)>0 do i:=i+1; while f(p[j],mid,p0)<0 do j:=j-1; if i<=j then begin t:=p[i];p[i]:=p[j];p[j]:=t; i:=i+1;j:=j-1; end; until i>j; if i<r then qsort(i,r,p0); if l<j then qsort(l,j,p0);end;begin read(n); while n<>0 do begin min:=maxlongint;x1:=0;i1:=0; for i:=1 to n do begin read(x[i],y[i]); if (min=y[i])and(x1>x[i]) then begin x1:=x[i];i1:=i;end; if min>y[i] then begin min:=y[i];x1:=x[i];i1:=i;end; end; p0.x:=x1;p0.y:=min; l:=0; for i:=1 to n do if i<>i1 then begin l:=l+1; p[l].x:=x[i]; p[l].y:=y[i]; end; qsort(1,n-1,p0); fillchar(s,sizeof(s),0); tot:=1; s[1]:=p0; for i:=1 to n-1 do begin while (tot>=2)and(f(s[tot-1],p[i],s[tot])>0) do tot:=tot-1; tot:=tot+1; s[tot]:=p[i]; end; ans:=0; for i:=1 to tot-1 do ans:=ans+sqrt(sqr(s[i].x-s[i+1].x)+sqr(s[i].y-s[i+1].y)); if tot>2 then ans:=ans+sqrt(sqr(s[tot].x-s[1].x)+sqr(s[tot].y-s[1].y)); writeln(ans:0:2); read(n); end;end.
0 0
- hdu1392——凸包模板
- hdu1392 凸包
- HDU1392+凸包
- 凸包:HDU1392(ZJU1453)
- 凸包 hdu1392
- acm几何凸包hdu1392
- hdu1392凸包.叉乘
- HDU1392--Surround the Trees--凸包
- 凸包问题 hdu1392 Surround the Trees
- HDU1392 Surround the Trees 简单凸包
- 凸包模版 HDU1392 Surround the Trees
- 【凸包】HDU1392 Surround the Trees
- 计算几何--凸包--Andrew算法--HDU1392
- HDU1392 Surround the Trees(凸包)
- hdu1392 Surround the Trees 凸包
- hdu1392标准求凸包模板
- hdu1392(Surround the Trees)凸包问题
- HDU1392:Surround the Trees(凸包问题)
- Java基础视频教程第10天_面向对象之异常2、包
- COREANIMATION中如何自定义动画属性
- 监控视频编码研究进展摘要汇总
- 1503150049-蓝桥杯-历届试题 错误票据
- 各种妄自菲薄的想法全都掰掰!
- hdu1392——凸包模板
- Neat Stuff to Do in List Controls Using Custom Draw
- Hibernate参考手册学习与实践:配置
- android之各类传感器使用详解
- oracle 12c grid db 安装的的checklist
- 零点
- 关于Hrris角点检测的一点理解
- 【leetcode】Longest Substring Without Repeating Characters
- 软件项目质量管理