URAL 1117. Hierarchy(DP)】的更多相关文章

题目链接 这破题,根本看不懂题意啊...题意:一棵中序遍历是1 2 3 4 5...的满二叉树,从a a+1 a+2 a+3 b,总共多少步.x到y的距离为中间有多少个点.a > b没注意2Y. #include <cstring> #include <cstdio> #include <string> #include <iostream> #include <algorithm> #include <cmath> #incl…
题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17662 题目大意:树枝上间连接着一坨坨苹果(不要在意'坨'),给定留下m根树枝,问最后剩下的最多苹果是多少. 解题思路: 其实意思和Vijos 1180(选课)的意思差不多.只不过权在边而已. 首先建无向图dfs. for(f+1...j....cost) for(1....k...j-cost) 其中f为当前已经dfs子结点个数.之所以+1,是因为当前点也需要…
http://acm.timus.ru/problem.aspx?space=1&num=1039 1039. Anniversary Party Time limit: 0.5 secondMemory limit: 8 MB Background The president of the Ural State University is going to make an 80'th Anniversary party. The university has a hierarchical st…
题目链接 我用的比较传统的办法...单调队列优化了一下,写的有点搓,不管怎样过了...两个单调队列,存两个东西,预处理一个标记数组存... #include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <map> #include <ctime> #include <cmath> #include <algorit…
题目链接 这题不难啊...标记一下就行了.表示啥想法也没有. #include <cstring> #include <cstdio> #include <string> #include <iostream> #include <algorithm> #include <cmath> #include <map> using namespace std; #define INF 100000000 ]; ]; ]; ];…
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17662 思路:典型的树形dp,处理的时候类似于分组背包,dp[i][j]代表以i为根的树取j个分支获得的最大值. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> using name…
1056. Computer Net Time limit: 2.0 second Memory limit: 64 MB Background Computer net is created by consecutive computer plug-up to one that has already been connected to the net. Each new computer gets an ordinal number, but the protocol contains th…
题目传送门http://acm.timus.ru/problem.aspx?space=1&num=1057 最近在学习数位dp,具体姿势可以参照这篇论文:http://wenku.baidu.com/view/d2414ffe04a1b0717fd5dda8.html?re=view #include <cstdio> #include <iostream> #include <cstring> using namespace std; const int m…
http://acm.timus.ru/problem.aspx?space=1&num=1017 题意:有n块砖,要求按照严格递增的个数摆放成楼梯,求楼梯的摆放种类数. 思路:状态转移方程:dp[i][j]=sum(dp[i-j][k]), 0 < k < j; i 表示砖的总数,j表示最高的那层的个数. #include <stdio.h> #include <string.h> #define LL long long ; LL dp[N][N]; int…
水题. #include <cstring> #include <cstdio> #include <string> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <cmath> using namespace std; #define INF 100000000 ][]; ][]; in…