题意 : 给出 6 枚硬币的面值,然后要求求出对于 1~100 要用所给硬币凑出这 100 个面值且要求所用的硬币数都是最少的,问你最后使用硬币的平均个数以及对于单个面值所用硬币的最大数. 分析 :  问题建模就是属于完全背包了,但是和普通的完全背包不一样,这题可以使用硬币的负数值,其实面对负数面值的情况,解决方法将更新数序和普通完全背包的更新顺序相反即可,然后正反更新两次就能得出最后的答案了.在普通物品重量只有正数的情况下对于一个 dp[i] 是从下标值小于 i 的状态转移而来,为了达到物品能…
Description On January 1st 2002, The Netherlands, and several other European countries abandoned their national currency in favour of the Euro. This changed the ease of paying, and not just internationally. A student buying a 68 guilder book before J…
题意: 给定6个硬币的币值, 问组成1~100这些数最少要几个硬币, 比如给定1 2 5 10 20 50, 组成40 可以是 20 + 20, 也可以是 50 -10, 最少硬币是2个. 分析: 这道题可以转化成是一道最短路的方法去做, 设一开始的起点为0(什么硬币都不取), 然后每个点都有12条路(对应正负6种币值), 每条路的权值为1, 令dis[maxn]初始化为inf, 求出dis[1]~dis[100]即可. 但是最大值maxn要取比100更大, 比如 构造100的最优方法为51+5…
背包 要么 BFS 意大利是说给你几个基本的货币,组成 1~100 所有货币,使用基本上的货币量以最小的. 出口 用法概率.和最大使用量. 能够BFS 有可能 . 只是记得数组开大点. 可能会出现 100 = 99+99 -98 的情况. 背包是先做一个全然背包,求得最少可能由多少相加. 然后做一个 01背包,看是否能被 减. 背包: #include<cstdio> #include<cstring> #include<string> #include<queu…
Euro Efficiency Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) Total Submission(s) : 12   Accepted Submission(s) : 3 Problem Description On January 1st 2002, The Netherlands, and several other European countries aban…
Q: 01背包最后返回什么 dp[v], v 是多少? A: 普通01背包需要遍历, 从大到小. 但此题因为物品的总重量必定大于背包容量, 所以直接返回 dp[V] 即可 update 2014年3月14日11:22:55 1. 几个月后, 感觉返回的不应该是 dp[V], 二是 dp[0...V] 中的最大值 Description Dearboy was so busy recently that now he has piles of clothes to wash. Luckily, h…
题目链接:http://poj.org/problem?id=2184 Cow Exhibition Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9479   Accepted: 3653 Description "Fat and docile, big and dumb, they look so stupid, they aren't much  fun..."  - Cows with Guns by…
这道题目和抢银行那个题目有点儿像,同样涉及到包和物品的转换. 我们将奶牛的两种属性中的一种当作价值,另一种当作花费.把总的价值当作包.然后对于每一头奶牛进行一次01背包的筛选操作就行了. 需要特别注意的是,当x小于0的时候,循环应该是正向的,不明白的话,好好想想01背包的一维解法为什么是逆向的. #include<stdio.h> #include<string.h> #define MAX 99999999 #define N 201005 int dp[N]; int Max(…
Q: 额外添加了最大高度限制, 需要根据 alt 对数据进行预处理么? A: 是的, 需要根据 alt 对数组排序 Description The cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks with w…
Cow Exhibition Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10342   Accepted: 4048 Description "Fat and docile, big and dumb, they look so stupid, they aren't much fun..." - Cows with Guns by Dana Lyons The cows want to prove to…