摘要:
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3339晚上看图论500的时候看到一个最短路+背包的题,有点感兴趣,于是花了一个多小时A了这题。题目大意:恐怖分子欲炸地球,引爆核弹需要用一半的电。而电分布在不同的电站。每个电站都存有不同的电。目的是派出坦克,毁坏电站,使其无法引爆。给出无向图,要求以最小总距离,毁坏一半以上的电。 注意每个电站都需要一个坦克。每个电站都有自己的花费(0到它的最短路),以及价值(电量)。于是转化为最少的花费去点一半以上电量问题。 本题还有一些细节需要注意。AC代码:#include<iostream>
#i 阅读全文
随笔分类 - 背包问题
HDU 1114Piggy-Bank(完全背包) 解题报告
2012-07-29 21:10 by javaspring, 176 阅读, 收藏,
摘要:
Problem DescriptionBefore ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some ACM member has any small money, he takes all the coins and throws 阅读全文
HDU 2546 饭卡(01背包) 解题报告
2012-07-18 09:10 by javaspring, 162 阅读, 收藏,
摘要:
原文链接: http://acm.hdu.edu.cn/showproblem.php?pid=2546昨天吧背包九讲中最基础的01背包看完,做了2602。结果晚上比赛相同题目却做不出。。苦想几个小时。。。解题思路:要使剩余钱最少,应该留下块钱买最贵的东西(标记为t)(注意金额m<5 的情况!!) 接下来就是用剩下的m-5元买除t以外的菜。每种菜只能买一次。就构成背包问题。代码:#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include& 阅读全文