题意可抽象为:N个包中每个包容量是T[i],每个包都拿一些,设拿出的总数为sum时的方案数为q,求max(q) 设dp[i][j]为拿了前i个包,共拿出了j物品时的方案数.那么 for i=1 to n for j=0 to sum for k=0 to t[i] dp[i][j]+=dp[i-1][j-k] 但是注意这题中间过程就得取MOD,然而这题求的却是最大值取模而不是取模之后的最大值 [这俩并不一样 可以打表得知dp[N][sum{T[i]}/2]是最大值 #include <iostr…
Partial Tree Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5534 Description In mathematics, and more specifically in graph theory, a tree is an undirected graph in which any two nodes are connected by exactly…
B. Modulo Sum Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/B Description You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such…
http://ac.nbutoj.com/Problem/view.xhtml?id=1479 [1479] How many 时间限制: 1000 ms 内存限制: 65535 K 问题描述 There are N numbers, no repeat. All numbers is between 1 and 120, and N is no more than 60. then given a number K(1 <= K <= 100). Your task is to find o…
题目:http://acm.fzu.edu.cn/problem.php?pid=2214 (http://www.fjutacm.com/Problem.jsp?pid=2053) 这题看起来是一题普通背包题,但是你会发现相对价格来说,体积太大了,此时只要将体积看为价格,价格看为体积,然后再来一个普通的背包DP算法就好了: #include<stdio.h> #include<algorithm> using namespace std; struct N { int w, v;…