状压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 ;
}

最新文章

  1. ZeroMQ接口函数之 :zmq_msg_recv - 从一个socket中接受一个消息帧
  2. 35、重新复习html与css(1)
  3. 关于Plupload结合上传插件jquery.plupload.queue的使用
  4. iBatis.Net(C#)SQL数据映射
  5. Eclipse插件项目 引用其他类库的方法(jar)
  6. 如何查找STM32开发资料
  7. [转] JavaScript 原型理解与创建对象应用
  8. JAVA基础——运算符和表达式
  9. 设计模式之桥接模式(Bridge模式)
  10. Linux Shell脚本攻略学习总结:三
  11. Maven-常用插件
  12. Android remount命令的两种写法
  13. Qt编写自定义控件属性设计器
  14. python之udp协议的套接字
  15. 使用IDEA进行Lua代码调试、自动提示、代码跳转、智能重命名
  16. JavaScript indexOf() 方法详解
  17. 201709025工作日记--更新UI方法
  18. http协议之 COOKIE
  19. 一个Keygen,参考参考
  20. python全栈开发从入门到放弃之函数基础

热门文章

  1. SQL基本操作——函数
  2. VC++ 遍历文件夹
  3. Caffe2:添加CUDA路径
  4. Pycharm:debug调试时使用参数
  5. CAD绘制一个角度标注(com接口VB语言)
  6. CAD动态绘制样条线(com接口)
  7. Ansible 利用playbook批量部署Nginx
  8. wing ide破解
  9. 293. [NOI2000] 单词查找树——COGS
  10. mongodb数据库的导出与导入