摘要: HDU 1003 相关链接 HDU 1231题解 题目大意:给定序列个数n及n个数,求该序列的最大连续子序列的和,要求输出最大连续子序列的和以及子序列的首位位置 解题思路:经典DP,可以定义dp[i]表示以a[i]为结尾的子序列的和的最大值,因而最大连续子序列及为dp数组中的最大值。 状态转移方程: 阅读全文
posted @ 2016-02-19 01:01 tan90丶 阅读(4349) 评论(0) 推荐(1) 编辑
摘要: HDU 2717 题目大意:在x坐标上,农夫在n,牛在k。农夫每次可以移动到n-1, n+1, n*2的点。求最少到达k的步数。 思路:从起点开始,分别按x-1,x+1,2*x三个方向进行BFS,最先找到的一定是最小的步数。 /* HDU 2717 Catch That Cow BFS */ #in 阅读全文
posted @ 2016-02-07 12:17 tan90丶 阅读(193) 评论(0) 推荐(0) 编辑
摘要: POJ 2251 题目大意: 给出一三维空间的地牢,要求求出由字符'S'到字符'E'的最短路径,移动方向可以是上,下,左,右,前,后,六个方向,每移动一次就耗费一分钟,要求输出最快的走出时间。不同L层的地图,相同RC坐标处是相连通的。(.可走,#为墙) 解题思路:从起点开始分别往6个方向进行BFS( 阅读全文
posted @ 2016-02-07 00:12 tan90丶 阅读(192) 评论(0) 推荐(0) 编辑
摘要: HDU 2096 /* HDU 2096 小明A+B 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen("D:\\input.txt", "r", stdin); #endif int a, b, c, n; scanf("%d", 阅读全文
posted @ 2016-01-24 21:32 tan90丶 阅读(178) 评论(0) 推荐(0) 编辑
摘要: HDU 2095 find your present (2) 解法一:使用set 利用set,由于只有一个为奇数次,对一个数进行查询,不在集合中则插入,在集合中则删除,最后剩下的就是结果 /* HDU 2095 find your present (2) 水题 */ #include <cstdio 阅读全文
posted @ 2016-01-23 21:20 tan90丶 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 所谓顺序表,即线性表的顺序存储结构。下面给出的是数据结构 线性表的定义。 ADT List{ 数据对象: 线性表的数据对象的集合为{a1,a2,a3,...,an},每个元素的类型为ElemType。 数据关系: 除第一个元素a1外,每一个元素有且只有一个直接前驱元素,除了最后一个元素an外,每个元 阅读全文
posted @ 2015-12-29 00:09 tan90丶 阅读(903) 评论(1) 推荐(0) 编辑
摘要: HDU 2085 核反应堆 /* HDU 2085 核反应堆 简单递推 */ #include <cstdio> const int N = 35; long long a[N], b[N]; //a表示高能质点数目,b表示低能质点数目 int main() { #ifdef _LOCAL freo 阅读全文
posted @ 2015-12-28 03:23 tan90丶 阅读(163) 评论(0) 推荐(0) 编辑
摘要: HDU 2083 简易版之最短距离 /* HDU 2083 简易版之最短距离 */ #include <cstdio> #include <algorithm> using namespace std; const int maxn = 505; int a[maxn]; int main() { 阅读全文
posted @ 2015-12-28 03:11 tan90丶 阅读(258) 评论(0) 推荐(0) 编辑
摘要: HDU 2084 数塔 从下往上递推,状态转移方程 dp[i][j] = max( dp[i+1][j], dp[i+1][j+1]) + a[i][j]; /* HDU 2084 数塔 入门DP */ #include <cstdio> const int N = 105; int dp[N][N 阅读全文
posted @ 2015-12-27 04:55 tan90丶 阅读(199) 评论(0) 推荐(0) 编辑
摘要: HDU 2082 找单词 起码通过这题,知道了母函数是什么东西,值得一做。 /* HDU 2082 找单词 母函数 */ #include <cstdio> #include <cstring> const int N = 50; int num[30], c1[N + 10], c2[N + 10 阅读全文
posted @ 2015-12-27 03:45 tan90丶 阅读(201) 评论(0) 推荐(0) 编辑