HDURevenge of Segment Tree(第二长的递增子序列)
题目链接
题目大意:这题是求第二长的递增子序列。
解题思路:用n^2的算法来求LIS,但是这里还要记录一下最长的那个序列是否有多种组成方式,如果>= 2, 那么第二长的还是最长的LIS的长度,否则就是LIS - 1;
代码:
#include
#include
#include
using...
分类:
其他好文 时间:
2014-11-02 22:37:47
阅读次数:
177
HDU5086Revenge of Segment Tree(数论)
题目链接
题目大意:给出长度为n的数组,然后要求累计里面的每个子串的和。
解题思路:枚举起点和终点,判断每个数属于多少条线段,那么这个数就要被加这么多次。可以得出每个位置被加次数的公式: i
(n - i + 1);那么结果就是累计(arr[i] i) mod * (n - i + 1) % mod,注意两...
分类:
其他好文 时间:
2014-11-02 22:36:32
阅读次数:
169
最近学习《C Primer Plus》位操作部分,结合书上的编程实例来巩固这部分知识点。 1 //使用位运算显示二进制数 2 #include 3 char *itobs( int, char*); //integer to binary string 4 vo...
分类:
其他好文 时间:
2014-11-02 22:32:34
阅读次数:
453
算法能力一直不好,决定利用晚上和假期时间多做点算法题,动动手,提高自己。大家看到我的水平低还望莫要嘲笑,嘻嘻。 这一题呢是LeetCode上的对称树问题, Given a binary tree, check whether it is a mirror of itself (ie, sym...
分类:
其他好文 时间:
2014-11-02 22:29:08
阅读次数:
231
1.JDOM介绍 JDOM的官方网站是http://www.jdom.org/,JDOM解析用到的jar包可以在http://www.jdom.org/dist/binary/中下载,最新的JDOM2的版本是2.0.5,JDOM1的版本是1.1.3,根据官网中的介绍可以知道。JDOM是一个在基于内存...
分类:
其他好文 时间:
2014-11-02 22:17:28
阅读次数:
310
应该就是算 线段树的 单点更新吧.但一开始给了我一个错觉 是二维线段树 我也是醉了tree[root].x// x = L || R表示root这个结点表示的是L - > R这个区间tree[root].leftLen//表示 root这个结点所在的区间现在还存在的最长连续格子数更让人郁闷的是 我用...
分类:
其他好文 时间:
2014-11-02 20:49:31
阅读次数:
194
http://acm.hdu.edu.cn/showproblem.php?pid=5086#include #include #include #include #include #include #include #include #define mod 1000000007using name...
分类:
其他好文 时间:
2014-11-02 20:48:56
阅读次数:
156
mooc的作业本来以为是很简单,真正写下去才知道不简单。每个都略有技巧,细细琢磨#include #include int all, top;class TreeNode{ public: int value; TreeNode* left; Tree...
分类:
编程语言 时间:
2014-11-02 19:30:26
阅读次数:
276
Binary String Matching描述Given two strings A and B, whose alphabet consist only ‘0’ and ‘1’. Your task is only to tell how many times does A appear as ...
分类:
其他好文 时间:
2014-11-02 16:09:51
阅读次数:
151
Revenge of Segment TreeProblem DescriptionIn computer science, a segment tree is a tree data structure for storing intervals, or segments. It allows q...
分类:
其他好文 时间:
2014-11-02 12:20:55
阅读次数:
191