HDUOJ Clear All of Them I 状压DP
Clear All of Them I
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 122768/62768 K (Java/Others)
Total Submission(s): 1455 Accepted Submission(s): 484
There are 2 * n enemies in the map. Your task is to clear all of them with your super laser gun at the fixed position (x, y).
For
each laser shot, your laser beam can reflect 1 times (must be 1 times),
which means it can kill 2 enemies at one time. And the energy this shot
costs is the total length of the laser path.
For example, if you
are at (0, 0), and use one laser shot kills the 2 enemies in the order
of (3, 4), (6, 0), then the energy this shot costs is 5.0 + 5.0 = 10.
00.
Since there are 2 * n enemies, you have to shot n times to
clear all of them. For each shot, it is you that select two existed
enemies and decide the reflect order.
Now, telling you your
position and the 2n enemies’ position, to save the energy, can you tell
me how much energy you need at least to clear all of them?
Note that:
> Each enemy can only be attacked once.
> All the positions will be unique.
> You must attack 2 different enemies in one shot.
> You can’t change your position.
For each case:
There are 2 integers x and y in the first line, which means your position.
The second line is an integer n(1 <= n <= 10), denote there are 2n enemies.
Then there following 2n lines, each line have 2 integers denote the position of an enemy.
All the position integers are between -1000 and 1000.
each test case: output the case number as shown and then print a
decimal v, which is the energy you need at least to clear all of them
(round to 2 decimal places).
0 0
1
6 0
3 0
0 0
2
1 0
2 1
-1 0
-2 0
Case #2: 4.41
HDUOJ Clear All of Them I 状压DP的更多相关文章
- CF453B Little Pony and Harmony Chest (状压DP)
CF453B CF454D Codeforces Round #259 (Div. 2) D Codeforces Round #259 (Div. 1) B D. Little Pony and H ...
- loj 1316(spfa预处理+状压dp)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=27024 题意:求0-(n-1)的经过最多的标记的点的最短路. 思路 ...
- HDU 3920Clear All of Them I(状压DP)
HDU 3920 Clear All of Them I 题目是说有2n个敌人,现在可以发n枚炮弹,每枚炮弹可以(可以且仅可以)打两个敌人,每一枚炮弹的花费等于它所行进的距离,现在要消灭所有的敌人 ...
- hdu 4739 状压DP
这里有状态压缩DP的好博文 题目:题目比较神,自己看题目吧 分析: 大概有两种思路: 1.dfs,判断正方形的话可以通过枚举对角线,大概每次减少4个三角形,加上一些小剪枝的话可以过. 2.状压DP,先 ...
- [BZOJ 1072] [SCOI2007] 排列perm 【状压DP】
题目链接:BZOJ 1072 这道题使用 C++ STL 的 next_permutation() 函数直接暴力就可以AC .(使用 Set 判断是否重复) 代码如下: #include <io ...
- BZOJ 3446: [Usaco2014 Feb]Cow Decathlon( 状压dp )
水状压dp. dp(x, s) = max{ dp( x - 1, s - {h} ) } + 奖励(假如拿到的) (h∈s). 时间复杂度O(n * 2^n) ------------------- ...
- 【XSY2745】装饰地板 状压DP 特征多项式
题目大意 你有\(s_1\)种\(1\times 2\)的地砖,\(s_2\)种\(2\times 1\)的地砖. 记铺满\(m\times n\)的地板的方案数为\(f(m,n)\). 给你\(m, ...
- 【BZOJ4042】【CERC2014】parades 状压DP
题目大意 给你一棵\(n\)个点的树和\(m\)条路径要求你找出最多的路径,使得这些路径不共边.特别的,每个点的度数\(\leq 10\). \(n\leq 1000,m\leq \frac{n(n- ...
- bzoj2004 矩阵快速幂优化状压dp
https://www.lydsy.com/JudgeOnline/problem.php?id=2004 以前只会状压dp和矩阵快速幂dp,没想到一道题还能组合起来一起用,算法竞赛真是奥妙重重 小Z ...
随机推荐
- 关于Parse库的配置问题
在使用Parse的一些相关服务时候,需要下载Parse的SDK,除了需要添加相应的系统框架和库的支持 AudioToolbox.framework CFNetwork.framework CoreGr ...
- JavaScript中七种函数调用方式及对应 this 的含义
this 在 JavaScript 开发中占有相当重要的地位,不过很多人对this这个东西都感觉到琢磨不透.要真正理解JavaScript的函数机制,就非常有必要搞清楚this到底是怎么回事. 函数调 ...
- android intent 隐式意图和显示意图(activity跳转)
android中的意图有显示意图和隐式意图两种, 显示意图要求必须知道被激活组件的包和class 隐式意图只需要知道跳转activity的动作和数据,就可以激活对应的组件 A 主activity B ...
- HTTP 404 - 未找到文件 怎么样解决
找不到网页 您要查看的网页可能已被删除.名称已被更改,或者临时不可用. -------------------------------------------------------------- ...
- Linux学习笔记总结--ssh认证登录
原理简介 SSH证书认证登录的基础是一对唯一匹配密钥: 私钥(private key)和公钥(public key).公钥用于对数据进行加密,而且只能用于加密.而私钥只能对使用所匹配的公钥,所加密过的 ...
- Windows Server 2008 R2 域控制器部署指南
一.域控制器安装步骤: 1.装 Windows Server 2008 R2并配置计算机名称和IP地址(见 附录一) 2.点击“开始”,在“搜索程序和文件”中输入Dcpromo.exe后按回车键: 3 ...
- .net+easyui系列--datagrid
加载CSS <link href="../../Public/easyui/SiteEasy.css" rel="stylesheet" type=&qu ...
- div a块状布局
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- (转)php 获取今日、昨日、上周、本月的起始时间戳和结束时间戳的方法
php 获取今日.昨日.上周.本月的起始时间戳和结束时间戳的方法,主要使用到了 php 的时间函数 mktime. 下面首先还是直奔主题以示例说明如何使用 mktime 获取今日.昨日.上周.本月的起 ...
- Android增加监听的三种实现方式
在Android中,为一个按钮增加监听的方式有五种 1.匿名内部类 @Override protected void onCreate(Bundle savedInstanceState) { sup ...