标签 - 杂OJ

? 解题记录 ? ? 杂OJ ? ? 亚线性筛 ?    2018-01-18 13:56:15    451    0    0
莫比乌斯函数,由德国数学家和天文学家莫比乌斯提出。梅滕斯(Mertens)首先使用μ(n)(miu(n))作为莫比乌斯函数的记号。具体定义如下: 如果一个数包含平方因子,那么miu(n) = 0。例如:miu(4), miu(12), miu(18) = 0。 如果一个数不包含平方因子,并且有k个不同的质因子,那么miu(n) = (-1)^k。例如:miu(2), miu(3), miu(30) = -1,miu(1), miu(6), miu(10) = 1。 给出一个区间[a,b],S(a,b) = miu(a) + miu(a + 1) + ...... miu(b)。 例如:S(3
? 解题记录 ? ? 杂OJ ? ? 回文自动机 ?    2017-11-25 11:51:21    403    0    0
411. Petya the Hero Time limit per test: 0.25 second(s) Memory limit: 65536 kilobytes input: standard output: standard Petya has come back from the Berland-Birland War, and now he is fond of gathering his friends and narrating his heroic deeds. You have probably heard the story telling that Petya,
? 解题记录 ? ? Manacher ? ? 杂OJ ? ? 回文自动机 ?    2017-09-16 14:22:13    477    1    0
 回文串是指aba、abba、cccbccc、aaaa这种左右对称的字符串。 输入一个字符串Str,输出Str里最长回文子串的长度。   Input输入Str(Str的长度 <= 100000)Output输出最长回文子串的长度L。Sample Input daabaacSample Output 5 一个标准的Manacher,可以看看这篇博客,讲的很清楚:我就是“博客”。另外突然发现max,min好慢啊,而且其中的两种情况可以合并。附代码:#include<cstdio> #include<algorithm> #include<cs
? 解题记录 ? ? Manacher ? ? 杂OJ ?    2017-09-16 14:05:32    361    0    0
Description全部由小写字母构成且长度不超过 100000 的非空字符串,求最长的连续子字符串 使得该字符串与其反转字符串相等Input输入包含多组测试数据,每组数据一行,为一个长度不超过 100000 的非空字符串Output每组数据输出一行,为最长的连续子字符串的长度Sample Inputabcbad abccba abcba abbacc ccabbaSample Output5 6 5 4 4根据今天连WA带TLE的经验可以归纳出在写Manacher的时候需要注意这几点:    1、不同case之间要清零清干净&nb
? 解题记录 ? ? 杂OJ ? ? 动态规划 ?    2017-09-13 21:27:22    381    0    0
有一个字符串S,求S最少可以被划分为多少个回文串。 例如:abbaabaa,有多种划分方式。 a|bb|aabaa - 3 个回文串 a|bb|a|aba|a - 5 个回文串 a|b|b|a|a|b|a|a - 8 个回文串 其中第1种划分方式的划分数量最少。 Input输入字符串S(S的长度<= 5000)。Output输出最少的划分数量。Sample Input abbaabaaSample Output 3​首先我们看见回文串问题可以模仿Manacher向空隙中填满'#'符号。然后可以推知DP转移方程dp[i + j] = min(dp[i + j], dp[i - j