zoj 2822 Sum of Different Primes (01背包)】的更多相关文章

///给你n 求他能分解成多少个的不同的k个素数相加之和 ///01背包,素数打表 # include <stdio.h> # include <algorithm> # include <string.h> # include <math.h> # include <iostream> using namespace std; int cot; int used[1500]; int prime[1500]; void sushu()///素数…
题目链接: POJ:id=3132">http://poj.org/problem?id=3132 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemCode=2822 Description A positive integer may be expressed as a sum of different prime numbers (primes), in one way or another. Given two…
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3956 题意 给出N组Hi Ci 然后 要选出若干个 使得 这个式子的值最大 然后是可以不选的,这个式子的值就是0 思路 因为 Ci 的范围特别小,我们就可以用Ci 来当做容量 进行01背包 其实在做题的时候有一个问题 就是 ci 并不是连续的 如果 给出一组数据 3 10 1 5 1 2 10 那个ci 的最大就是 12 但是 其实有效值 能够选择的 Ci 其实…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3703 Happy Programming Contest Time Limit: 2 Seconds      Memory Limit: 65536 KB In Zhejiang University Programming Contest, a team is called "couple team" if it consists of only two s…
  CD  You have a long drive by car ahead. You have a tape recorder, but unfortunately your best music is on CDs. You need to have it on tapes so the problem to solve is: you have a tape N minutes long. How to choose tracks from CD to get most out of…
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3654 题意:把n拆成k个不同素数的和,有多少种拆法. dp(i,j)表示数字为i时,有j个不同素数和的组合数. 先枚举素数的上界k,注意是不同素数,那就再在k个素数中做01背包,dp(i,j)+=dp(i-p,j-1)统计出现次数就行了. #include <bits/st…
传送门 题意简述:输入一个数组an" role="presentation" style="position: relative;">anan. 对于所有2n−1" role="presentation" style="position: relative;">2n−12n−1个非空子集,每个子集的权值是包含的所有元素之和. 求这2n−1" role="presentatio…
B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output 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…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3956 题意:就是给你Hi,Ci的值,问怎么取使得下面那个式子的值最大: 理解:当时做了好久以为是贪心>_<.后来看别人的题解发现是01背包,现在学了01背包以后看就好理解多了. 因为每个值都是取或不取,所以容易想到是01背包.而且Hi的范围是[1,10000],Ci的范围是[1,100],n是[1,500],所以明显可以发现Ci适合做“物品体积”,Hi做“物品价值”,Σ…
Course Selection System ZOJ - 3956 这个题目居然是一个01背包,我觉得好难想啊,根本就没有想到. 这个题目把题目给的转化为  ans = a*a-a*b-b*b 这个可以看成 当b不变的时候 a 越大越好. 这个就可以用01背包来解决 #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <algor…