摘要:
题目:给出一定(n)数量的砝码,每个砝码重a1,a2,a3。。。an, 问题:求出【1~sum】中(sum为各砝码总和)不能被称出的重量; 问题关键:天平两边都可以放砝码, 放在同一端:a[j+k]+=a[j] 不同端a[abs(j-k)]+=a[j] 假设原来的砝码都放在右端,则可以把新加的砝码放 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1171 01背包 #include<bits/stdc++.h> using namespace std; const int maxn = 1000*100 +100; int dp[maxn],v[5010]; 阅读全文
摘要:
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1007 01背包//需要多做这种题 能看到题想到这个思路 如果sum为奇数 比如 sum=5,那么sum/2 就是2 所以 总共的sum -dp[sum/2] 就是较大的那一 阅读全文
摘要:
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1086 思路 裸的多重背包 巩固一下刚学的骚操作 #include<bits/stdc++.h> using namespace std; const int maxn = 阅读全文
摘要:
http://poj.org/problem?id=1014 思路 大概是裸的多重背包 复杂度 #include<iostream> #include<cstdio> #include<algorithm> #include<string.h> using namespace std; const 阅读全文
摘要:
来源:http://acm.hdu.edu.cn/showproblem.php?pid=2082 qscvideo讲解:https://www.bilibili.com/video/av4356817/ 母函数 也就是所谓的生成函数 通过(1+x)(1+x+x2)将排列组合问题 换成求多项式系数的 阅读全文
摘要:
来源:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1050 答案有两种形式1.正常的最大连续序列 即ans1 2.开始+末尾的连续的一段,去掉中间,中间为什么去掉呢,因为中间那段和为负数,只要求出负数最大的连续子序列去掉 阅读全文
摘要:
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1183. 题意不再赘述。 分析:大概和LCS差不多的吧 但是我用LCS转换貌似错了 搜的网上的题解 大概就是 如果(dp[i-1][j-1] dp[i-1][j] dp[i] 阅读全文