状压dp+凸包

并没有看出来凸包的性质

首先答案一定在凸包上,然后每个凸包的角加起来是一个圆,那么就相当于凸包周长加一个圆了。然后预处理,再状压dp计算即可。

#include<bits/stdc++.h>
using namespace std;
const int N = ;
const double pi = acos(-);
struct points {
double x, y;
bool friend operator < (points A, points B)
{
return A.x == B.x ? A.y < B.y : A.x < B.x;
}
} point[N * ], p[N * ];
int n, m, cnt, top, kase;
double dp[ << N], d[ << N];
int st[N * ];
double cross(points x, points y, points z)
{
return (x.x - z.x) * (y.y - z.y) - (x.y - z.y) * (y.x - z.x);
}
double dis(points x, points y)
{
return sqrt((x.x - y.x) * (x.x - y.x) + (x.y - y.y) * (x.y - y.y));
}
double graham()
{
double ret = ;
top = ;
for(int i = ; i <= cnt; ++i)
{
while(top > && cross(p[i], p[st[top]], p[st[top - ]]) >= ) --top;
st[++top] = i;
}
int lim = top;
for(int i = cnt - ; i; --i)
{
while(top > lim && cross(p[i], p[st[top]], p[st[top - ]]) >= ) --top;
st[++top] = i;
}
for(int i = ; i < top; ++i) ret += dis(p[st[i]], p[st[i + ]]);
return ret;
}
int main()
{
while(scanf("%d%d", &n, &m))
{
if(!n && !m) break;
for(int i = ; i < n; ++i) scanf("%lf%lf", &point[i].x, &point[i].y);
sort(point, point + n);
for(int i = ; i < ( << n); ++i)
{
cnt = ;
for(int j = ; j < n; ++j) if(i & ( << j))
p[++cnt] = point[j];
dp[i] = graham() + * m * pi;
}
for(int i = ; i < ( << n); ++i)
for(int S = i; S; S = (S - ) & i)
dp[i] = min(dp[i], dp[S] + dp[i ^ S]);
printf("Case %d: length = %.2f\n", ++kase, dp[( << n) - ]);
}
return ;
}

uva1084的更多相关文章

随机推荐

  1. [Windows Server 2012] 杰奇CMS安全设置

    ★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com ★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频. ★ 本节我们将带领大家:JIEQI ...

  2. C#调用Win32 api时的内存操作

    一般情况下,C#与Win 32 Api的互操作都表现的很一致:值类型传递结构体,一维.二维指针传递IntPtr.在Win32 分配内存时,可以通过IntPtr以类似移动指针的方式读取内存.通过IntP ...

  3. 011--c数组--排序--组成最大数

    数组--排序--组成最大数   组成最大数   任意输入一个自然数,输出该自然数的各位数字组成的最大数.例如,输入 1593 ,则输出为 9531 . 输入: 自然数 n 输出: 各位数字组成的最大数 ...

  4. unable to get system library for the project

    当向eclipse导入项目实例后,项目上出现红叉的错误提示,在项目属性里的Java Build Path里发现了错误提示复选选项: unable to get system library for t ...

  5. gitlab 第1次提交代码到1个新仓库

    1.如果是本地刚刚搭建好git环境,第一次和gitlab服务器产生连接 参照这个文 https://www.cnblogs.com/kaerxifa/p/10929098.html 2.已经和gitl ...

  6. c#符号含义

    属性:(带手型图标)方法:(紫红色菱形)事件:(闪电)字段:(蓝色菱形) 还有很多,具体图标不好描述命名空间,类,接口,值类,枚举,清单或类信息项等

  7. 用shell编写dhcp自动获取脚本

    #!/bin/bash#net=$(ifconfig ens33 | awk -F'[ .]+' '/inet\>/{print $3"."$4"."$5 ...

  8. HTML学习笔记之HTML5新特性

    目录 1.拖放 2.画布 3.可伸缩矢量图形 4.地理定位 5.Web 存储 6.应用缓存 7.Web Worker 1.拖放 拖放是一种常见的特性,用于抓取对象以后拖到另一个位置,它是 HTML5 ...

  9. PAT 1113 Integer Set Partition

    Given a set of N (>1) positive integers, you are supposed to partition them into two disjoint set ...

  10. hdu2002 计算球体积【C++】

    计算球体积 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...