状压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. JS——dom

    节点的获取 <script> var div = document.getElementById("box");//返回指定标签 var div = document. ...

  2. SQL基本操作——GROUP BY

    GROUP BY 语句用于结合合计函数,根据一个或多个列对结果集进行分组. SQL GROUP BY 实例:我们拥有下面这个 "Orders" 表 O_Id OrderDate O ...

  3. ARX中类型强制转换

    比如 克隆 clone, 获得的是一个acrxobject, acrxobject *pobj=pployline->clone(); acdbpolyline *ppoly=acdbpolyl ...

  4. css页面布局总结

    W3C标准:是万维网制定的一系列标准,包括结构化标准语言(html.xml),表现 标准语言(css),行为标准语言(DOM,ECMAScript<javascript>)组成.这个标准倡 ...

  5. 利用 CSS animation 和 CSS sprite 制作动画

    CSS3 大大强化了制作动画的能力,但是如果要做出图案比较复杂的动画,选择 GIF 依然是一个不错的选择.今天给大家介绍一个使用 CSS animation 配合雪碧图(CSS sprite)来制作动 ...

  6. Java数组数据类型

    Java数组数据类型 数组是多个相同类型的数据的组合,数组中的元素可以是任何类型的数据: 一维数组 package com.ahabest.array; public class ArratTest ...

  7. P2080 增进感情

    题目背景 小明和小红的感情,是慢慢发展起来的. 题目描述 他们对对方分别有一个好感值.定义两人的亲密程度为两人的好感值之和. 如果他们的亲密程度达到V,则他们将走到一起.他们以后的生活将取决于两人的好 ...

  8. [LUOGU] 4933 大师

    \(Orz\) \(ljt12138!\) 设状态\(f[i][j]\)表示以\(i\)为结尾,公差为\(j\)的长度大于\(1\)的数列有几个. 然后转移方程就很好想了. \(k=H[i]-H[j] ...

  9. Scrapy下载器中间件用法示例

    1.爬虫文件httpbin.py # -*- coding: utf-8 -*- import scrapy class HttpbinSpider(scrapy.Spider): name = 'h ...

  10. git 的简单使用(3)

    Git鼓励大量使用分支: 查看分支:git branch 创建分支:git branch <name> 切换分支:git checkout <name> 创建+切换分支:git ...