
动态规划入门
软件丶Crazyxu
这个作者很懒,什么都没留下…
展开
-
等和的分隔子集 计蒜客
晓萌希望将1到N的连续整数组成的集合划分成两个子集合,且保证每个集合的数字和是相等。例如,对于N=3,对应的集合{1,2,3}能被划分成{3} 和 {1,2}两个子集合.这两个子集合中元素分别的和是相等的。对于N=3,我们只有一种划分方法,而对于N=7时,我们将有4种划分的方案。输入包括一行,仅一个整数,表示N的值(1≤N≤39)。输出包括一行,仅一个整数,晓萌可以划分对应N的集合的方案的个数。当...转载 2018-04-10 21:31:24 · 235 阅读 · 1 评论 -
Codeforces Round #500 Hills(一道dp题)
题目链接:http://codeforces.com/problemset/problem/1012/C这道题的思路是在前i个商品中,选出j个,然后对第i个进行区分选还是不选。dp方程为:dp[i][j][0] = min(dp[i-1][j][0],dp[i-1][j][1]);dp[i][j][1] = min(dp[i-2][j-1][0]+dis1(前面的数)+dis2(后面的)...原创 2018-07-31 15:31:18 · 286 阅读 · 0 评论 -
树的重心(简单的树形dp)
#include<vector>#include<algorithm>#include<cstring>#include<stdio.h>using namespace std;#define MAXN 1000vector<int>a[MAXN];int Get_num(int son,int fa){ int...原创 2018-07-24 13:28:09 · 609 阅读 · 0 评论 -
最大子独立集(简单的树形dp)
最大子独立集对于一棵有N个结点的无根树,选出尽量多的结点,使得任何两个结点均不相邻(称为最大独立集)。1 2输入 第1行:1个整数N(1 <= N <= 6000),表示树的结点个数,树中结点的编号从1..N接下来N-1行,每行2个整数u,v,表示树中的一条边连接结点u和v1 2 3输出 第1行:1个整数,表示最大独立集的结点个数1...原创 2018-07-24 12:40:08 · 422 阅读 · 0 评论 -
Robberies
Problem DescriptionThe aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become too greedy. He has decided to wo...原创 2018-04-19 23:33:41 · 1308 阅读 · 1 评论 -
POJ1837 [DP水题]
DescriptionGigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance. It orders two arms of negligible weight and each arm's length is 1...转载 2018-04-13 23:35:15 · 199 阅读 · 0 评论 -
C - Monkey and Banana (DAG模型题,简单的dp)
C - Monkey and Banana A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with so...原创 2018-04-30 13:31:02 · 279 阅读 · 0 评论 -
取数游戏
有如下一个双人游戏:N个正整数的序列放在一个游戏平台上,两人轮流从序列的两端取数,每次有数字被一个玩家取走后,这个数字被从序列中去掉并累加到取走该数的玩家的得分中,当数取尽时,游戏结束。以最终得分多者为胜。编一个执行最优策略的程序,最优策略就是使自己能得到在当前情况下最大的可能的总分的策略。你的程序要始终为两位玩家执行最优策略。输入第1行包括一个正整数N(2≤N≤100), 表示序列中正整数的个数...转载 2018-04-12 16:24:39 · 514 阅读 · 0 评论 -
计蒜客 单调减子序列
从一个由 NN 个整数排列组成的整数序列中,自左向右不连续的选出一组整数,可以组成一个单调减小的子序列(如从 [68, 69, 54, 64, 68, 64, 70, 67, 78, 62, 98, 87][68,69,54,64,68,64,70,67,78,62,98,87] 中我们可以选取出 [69, 68, 64, 62][69,68,64,62] 这个子序列;当然,这里还有很多其他...转载 2018-07-23 23:44:10 · 439 阅读 · 3 评论 -
poj 3267(dp水题)
DescriptionFew know that the cows have their own dictionary with W (1 ≤ W ≤ 600) words, each containing no more 25 of the characters 'a'..'z'. Their cowmunication system, based on mooing, is not ver...原创 2018-07-28 09:44:56 · 292 阅读 · 0 评论