poj1787 Charlie's Change】的更多相关文章

Description Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motorests. Charlie hates change. That is basically the setup of your next task.  Your program will be give…
思路: 完全背包,记录路径. 实现: #include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; ] = {, , , }; ], m; ], used[], path[]; int main() { ] >> c[] >> c[] >> c[], m || c[] || c[] || c[] || c[]) { memset(used, , sizeof used);…
http://poj.org/problem?id=1787   描述 Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motorests. Charlie hates change. That is basically the setup of your next task. Yo…
Charlie's Change Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3176   Accepted: 913 Description Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motores…
Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motorests. Charlie hates change. That is basically the setup of your next task. Your program will be given numbers and…
Time limit 1000 ms Memory limit 30000 kB description Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motorests. Charlie hates change. That is basically the setup of y…
Charlie's Change Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3792   Accepted: 1144 Description Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motore…
Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motorests. Charlie hates change. That is basically the setup of your next task. Your program will be given numbers and…
题目链接:http://poj.org/problem?id=1787 题意:有4种货币分别是1元,5元,10元,20元.现在告诉你这四种货币分别有多少个,问你正好凑出P元钱最多可以用多少货币.每种货币要用多少钱. 据说此题有完全背包的写法.. 我是按照多重背包写的,速度也不是很慢. 然后记录了下前驱. 刚开始全都写挫了..虽然现在也很挫.. 凑合着看吧 -- #include <cstdio> #include <algorithm> #include <cstring&g…
网上说是多重背包,因为要输出方案,还要记录下路径,百度一下题解就可以. 自己做的时候,还没了解过多重背包,该题直接往完全背包思考了.咖啡的钱看作总的背包容量,1.5.10.25分别代表四种物品的重量,可以取多次,但是有限制数量.设dp[j]为咖啡的价格为j时,所能花费的最多钱币数此外建立一个二维数组num[j][i],表示咖啡的价格为j时,花费的第i种货币的个数 状态转移方程:dp[j]=max(dp[j],dp[j-v[i]]+1)初始条件:dp[j]=-1,dp[0]=0; num[j][i…