摘要: 回文串定义:“回文串”是一个正读和反读都一样的字符串,比如“asddsa”或者“lovekevol”等等就是回文串。回文子串,顾名思义,即字符串中满足回文性质的子串。 这里我给出通过枚举回文串的中间位置i,然后不断向外扩展,直达有字符不相同。注意,这里长度为奇数和偶数的处理方式是不一样的。下面给... 阅读全文
posted @ 2015-09-09 10:48 Zeroinger 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=396 题目大意:求一个串的最小周期。 因为串很小,所以暴力可过,枚举周期即可,但是周期一定能... 阅读全文
posted @ 2015-09-05 21:58 Zeroinger 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3666 题目大意就是把前N个整数12345678910111213......依次写在一起,... 阅读全文
posted @ 2015-09-05 20:56 Zeroinger 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=276 题目大意: 猜数字游戏,给定答案序列和游戏者猜测的序列,统计有多少个数字位置正... 阅读全文
posted @ 2015-09-05 13:36 Zeroinger 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 题目大意:输入整数k,找到所有正整数x>=y,使得1/k=1/x+1/y. 分析:由1/k=1/x+1/y可以推得x=k*y/(y-k),我们只需要枚举即可,又因为x>=y,所以1/x#includeusing namespace std;const int maxn=10005;int x[m... 阅读全文
posted @ 2015-09-02 11:15 Zeroinger 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=666 题目大意是输入一个数n,按照从大到小的顺序输出所有如abcde/fighi=n的表达式... 阅读全文
posted @ 2015-09-01 20:28 Zeroinger 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2000因为n比较小,所以可以直接暴力。但我还是wa几次,因为少了换行,还是Cf好啊。 代码:... 阅读全文
posted @ 2015-09-01 17:37 Zeroinger 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 这道题就是很裸的一个最长下降子序列,算法类似最长上升子序列。最长上升子序列算法链接: 1:http://blog.csdn.net/z_zhangyinqian/article/details/47859617 2:http://blog.csdn.net/z_zhangyinqian/arti... 阅读全文
posted @ 2015-08-31 18:52 Zeroinger 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 相关描述: 连续子序列最大和,其实就是求一个序列中连续的子序列中元素和最大的那个。 比如例如给定序列: { -5,-2, 11, -4, 13, -5, -8 } 其最大连续子序列为{ 11, -4, 13 },最大和为20。 方法一:暴力 O(n^3) 算法描述: 暴力搞来就是枚举子... 阅读全文
posted @ 2015-08-30 16:10 Zeroinger 阅读(448) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=4014 Problem D. Dice Input file: dice.in Output file: dice.out Time limit: 3 seconds Memory limit: 256 megabytes A... 阅读全文
posted @ 2015-08-27 17:11 Zeroinger 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1950 其实就是求最长上升子序列,不过要用nlogn的算法n*n会超时。学习最长子序列算法见博客: 1:http://blog.csdn.net/z_zhangyinqian/article/deta... 阅读全文
posted @ 2015-08-27 13:45 Zeroinger 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 为了更好的介绍O(nlogn)算法,我们回顾一下一般的O(n^2)的算法。 令A[i]表示输入第i个元素,d[i]表示从A[1]到A[i]中以A[i]结尾的最长子序列长度。对于任意的0 d[i'],就这么简单。那么知道了S的值有什么用呢?或许聪明的读者已经看出来了,对于最长不下降子序列,只... 阅读全文
posted @ 2015-08-25 17:56 Zeroinger 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5256 Problem Description 我们有一个数列A1,A2...An,你现在要求修改数量最少的元素,使得这个数列严格递增。其中无论是修改前还是修改后,每个元素都必须是整数。 请输出... 阅读全文
posted @ 2015-08-25 14:23 Zeroinger 阅读(400) 评论(0) 推荐(0) 编辑
摘要: 这题目是经典的DP题目,也可叫作LIS(Longest Increasing Subsequence)最长上升子序列 或者 最长不下降子序列。很基础的题目,有两种算法,复杂度分别为O(n*logn)和O(n^2) 。 A. O(n^2)算法分析如下: (a[1]...a[n] 存的都是... 阅读全文
posted @ 2015-08-22 15:01 Zeroinger 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3292 Description This problem is based on an exercise of David Hilbert, who pedagogically suggested that one study... 阅读全文
posted @ 2015-08-21 12:49 Zeroinger 阅读(141) 评论(0) 推荐(0) 编辑
无觅关联推荐,快速提升流量