题目链接:https://vjudge.net/contest/217847#problem/A 题目大意:   现在有n种硬币,每种硬币有特定的重量cost[i] 克和它对应的价值val[i]. 每种硬币可以无限使用. 已知现在一个储蓄罐中所有硬币的总重量正好为m克, 问你这个储蓄罐中最少有多少价值的硬币? 如果不可能存在m克的情况, 那么就输出” This is impossible.”. 解题分析: 由于每种硬币可以无限使用, 所以是明显的完全背包问题,dp[i][j]为只用前i种硬币装满…
http://poj.org/problem?id=1384 Piggy-Bank Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7900 Accepted: 3813 Description Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income f…
Piggy-Bank 题目链接: http://acm.hust.edu.cn/vjudge/contest/130510#problem/F Description Before 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 Mone…
Piggy-Bank Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 10830   Accepted: 5275 Description Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from…
题意 给出一个存钱罐里的钱币重量 给出可能的n种钱币重量以及价值 求存钱罐中钱币的最小价值 若不可能另有输出 在裸的完全背包上加了一点东西 即判断这个背包能否被装满 初始化 dp[0]=0 其余的都使用for循环设置成INF 以达到求min的目的 最后如果dp[v]还是那么大就说明它根本没有通过前面的方式被改变 即 不能被装满 #include<stdio.h> #include<string.h> #include<algorithm> #include<map…
T了两发,DP方程很简单粗暴 dp[i][j][k]:用前i物品使得容量分别为j和k的背包恰好装满 背包的调用只需一次即可,第一次T就是每次check都丧心病狂地背包一次 对于sum的枚举,其实i j枚举到sum/2就可以了 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #define scan(a) scanf(…
题目链接:http://poj.org/problem?id=1745 Divisibility Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13431   Accepted: 4774 Description Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequen…
POJ 3181 Dollar Dayz(全然背包+简单高精度加法) id=3181">http://poj.org/problem?id=3181 题意: 给你K种硬币,每种硬币各自是1美元,2美元-K美元且能够无限使用,问你用上面K种硬币构成n美元的话有多少种方法? 分析: 本题是一道明显的全然背包问题, 只是本题还能够换一种方法来看: 整数n由前K个自然数构造, 一共同拥有多少种方法? (尽管本题要用到高精度加法, 可是非常easy, 不要被吓到哦) 首先是DP部分: 令dp[i][…
POJ 3211 Washing Clothes(01背包) http://poj.org/problem?id=3211 题意: 有m (1~10)种不同颜色的衣服总共n (1~100)件.Dearboy和她的girlfriend两个人要一起洗完所有衣服,为了预防色彩混合,他们每次仅仅能同一时候洗同一种颜色的衣服,给出洗完每件衣服所需的时间time和它的颜色color,求出Dearboy和她的girlfriend最少用多少时间能洗完毕所有衣服. 分析: 因为每种颜色的衣服是分开洗的, 所以我们…
Problem Description Before 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…