A sequence X_1, X_2, ..., X_n is fibonacci-like if: n >= 3 X_i + X_{i+1} = X_{i+2} for all i + 2 <= n Given a strictly increasing array A of positive ...
分类:
其他好文 时间:
2019-01-13 19:16:51
阅读次数:
192
"传送门" 前一题的加强版……求10个串的最长公共子串的长度。 OI Wiki上的解法我没看懂…… 朴素的想法还是对第一个串建立SAM,之后把后面的串不断地在上面匹配,对于每一个状态记录匹配最小值,所有状态取最大值。不过这样是会WA的…… 为啥呢?因为我们是对于每个状态取最小,然后最后在算答案的时候 ...
分类:
其他好文 时间:
2019-01-12 22:54:18
阅读次数:
177
"传送门" 求两个字符串最长公共子串的长度。 对于第一个串S,建立SAM,之后对于第二个串T,我们在上面和S进行匹配。首先从$t_0$开始,如果能成功匹配的话,那么我们让长度+1,同时更新答案。如果失配,那我们就跳parent树转移到其父节点的位置,并且把当前匹配长度变为其最长后缀长度即可。 最后统 ...
分类:
其他好文 时间:
2019-01-12 22:49:17
阅读次数:
222
什么是最长递增子序列(Longest Increasing Subsquence) 对于一个序列{3, 2, 6, 4, 5, 1},它包含很多递增子序列{3, 6}, {2,6}, {2, 4, 5}, {1} 其中最长的递增子序列是{2, 4, 5} 问题:对于长度为N的矢量D,如何找到它的最长 ...
分类:
编程语言 时间:
2019-01-12 20:54:24
阅读次数:
229
Unlucky year in Berland is such a year that its number n can be represented as n?=?xa?+?yb, where a and b are non-negative integer numbers. For exampl ...
分类:
其他好文 时间:
2019-01-11 22:14:10
阅读次数:
165
class Solution { public String longestCommonPrefix(String[] strs) { if(strs == null || strs.length ...
分类:
其他好文 时间:
2019-01-11 17:17:01
阅读次数:
161
$\color{ 0066ff}{ 题目描述 }$ 题面描述 给定一些字符串,求出它们的最长公共子串 输入格式 输入至多$10$ 行,每行包含不超过$100000$ 个的小写字母,表示一个字符串 输出格式 一个数,最长公共子串的长度 若不存在最长公共子串,请输出$0$ 。 $\color{ 0066 ...
分类:
其他好文 时间:
2019-01-10 21:54:03
阅读次数:
181
$\color{ 0066ff}{ 题目描述 }$ 输入2 个长度不大于250000的字符串,输出这2 个字符串的最长公共子串。如果没有公共子串则输出0 。 $\color{ 0066ff}{输入格式}$ 两个字符串 $\color{ 0066ff}{输出格式}$ 一个整数,为 所求答案 $\col ...
分类:
其他好文 时间:
2019-01-10 19:30:34
阅读次数:
153
class Solution { public int lengthOfLongestSubstring(String s) { int res = 0; int left = 0, right = 0; int counter = 0; Map map = new HashMap(); while ...
分类:
其他好文 时间:
2019-01-10 13:20:19
阅读次数:
115