随笔分类 - 数据结构
摘要:题目:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68990#problem/E 题目要求:p*e-x+ q*sin(x) + r*cos(x) + s*tan(x) + t*x2 + u = 0,求出x的值; where 0 <= x
阅读全文
摘要:题目:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68990#problem/O 题目需求:在数组中拿出两个数相加,再把结果放回数组中再如此反复,求最小的结果是多少。 题目解析:典型的哈弗曼编码的题目。和之前做过的合并果子如出一辙,因为
阅读全文
摘要:题目链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68990#problem/J 题目大意: 给一个没有加上括号的表达式且只有+ ,*两种操作符,然后要求随便怎样添加括号,求出这个表达式的最大值和最小值. 题目解析: 要求最大值,
阅读全文
摘要:链接: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2857 题目解析: 这是去年校赛的题目,当时没做出来,现在才补,真水,这题就是一个简单dp。 看第k个人画第m幅画的时候,要考虑两个时间,1.第k-
阅读全文
摘要:题目链接: http://poj.org/problem?id=1088 题目要求: 一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。求可以滑落的最长长度。 题目解析: 首先要先排一下序,因为只能高度递减才能滑行。之后就很简单了,就是简单DP。 即:要求的滑坡是一条节点递减并依次相邻
阅读全文
摘要:题目链接:http://poj.org/problem?id=1836 题目要求: 题目分析: 这题和UVA10534极其相似,因为刚做完,就果断粘贴复制了,唯一的不同是这次队列不是对称的,并且如果中间有两个士兵一样高是不用去掉的,(中间,仅限两个)。 我感觉这题是水过去的,我的代码只支持有一个最大
阅读全文
摘要:题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68553#problem/B 题目要求: Wavio是一个整数序列,具有以下特性: 1、Wavio序列的长度是奇数, 即 L = 2 * n + 1; 2、Wavio序列前 n+1
阅读全文
摘要:题目链接:http://poj.org/problem?id=3903 题目链接:http://poj.org/problem?id=1631 题目链接:http://poj.org/problem?id=1887 题目解析: 这两道题都是直接求最长上升子序列,没什么好说的。 POJ 3903这题n
阅读全文
摘要:问题描述: 一个数的序列bi,当b1 < b2 < ... < bS的时候,我们称这个序列是上升的。对于给定的一个序列(a1, a2, ..., aN),我们可以得到一些上升的子序列(ai1, ai2, ..., aiK),这里1 <= i1 < i2 < ... < iK <= N。比如,对于序列
阅读全文
摘要:地址:http://poj.org/problem?id=1159 题目需求: 给你一个字符串,求最少添加多少字符可以使之构成回文串。 题目解析: 简单做法是直接对它和它的逆序串求最长公共子序列长度len。n-len即为所求。(n为原串长度) 即 : 最少补充的字母数 = 原序列的长度 — 原串和逆
阅读全文
摘要:题目链接:http://blog.csdn.net/u014361775/article/details/42873875 题目解析: 给定两行字符串序列,输出它们之间最大公共子单词的个数 对于给的两个序列X 和 Y,用i 和 j分别作为它们的前缀指针,f[i][j]表示序列X的前缀Xi 和 序列Y
阅读全文
摘要:地址:http://poj.org/problem?id=3176 题目解析:没什么好说的,之前上课时老师讲过。从下往上找,每一个三角形的顶点可由两个角加上顶点的值 两种方式得到 ,用dp数组保存下最大值即可。
阅读全文
摘要:白书一:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=64609#overview 注意UVA没有PE之类的,如果PE了显示WA。 UVA401:Palindromes #include <iostream> #include <cstd
阅读全文
摘要:#include <iostream> #include <algorithm> #include <string> #include <cstring> #include <map> const int N=1000001; using namespace std; int tt=0;//用于存储
阅读全文
摘要:#include #include #include #include #define N 100010 using namespace std; int n,tt,le; char a[N][3]; int m[N],X[N]; struct node { int l,r,w; } q[4*N]; void pushup(int rt) { q[rt].w=q[rt>1...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1556 Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1698 Problem Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5023 Problem Description Corrupt governors always find ways to get dirty money. Paint something, then sell t
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5124 Problem Description John has several lines. The lines are covered on the X axis. Let A is a point which
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1757 Problem Description Lele now is thinking about a simple function f(x).If x < 10 f(x) = x.If x >= 10 f(x
阅读全文