http://poj.org/problem?id=3181 Dollar Dayz Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7997 Accepted: 2992 Description Farmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. During his…
http://poj.org/problem?id=3181 Description Farmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. During his first visit, the tools are selling variously for $1, $2, and $3. Farmer John has exactly $5 to…
解法 完全背包+大数...不想写大数了放个python得了 代码 dp=[0 for i in range(2000)] n,k=map(int,input().split()) num=[i for i in range(1,k+1)] dp[0]=1 for i in range(k): for j in range(num[i],n+1): dp[j]+=dp[j-num[i]] print(dp[n])…
这个题目要用到大数的加法,其他的,我没有感觉到有什么难想的......比较水的背包题,掠过..... #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int s[2000][2],dp[150],t[150][3]; int main() { int text; scanf("%d",&text); while(text--) { int…
nyoj 1091 还是01背包 描述 有n个重量和价值分别为 wi 和 vi 的物品,从这些物品中挑选总重量不超过W的物品,求所有挑选方案中价值总和的最大值 1 <= n <=40 1 <= wi <= 10^15 1 <= vi <= 10^15 1 <= W <= 10^15 分析:在做的时候毫无头绪,在网上看了其他大神的博客才AC了,数据超大无法使用之前的思路(超时且dp数组开不了这么大),但是由本题条件可知n的值非常小,可用递归配合剪枝解题 代码:…