摘要: 题意:若一个串t是A的子串且t不包含B,称t为A的合法子串。求A不同的合法子串的个数。思路:这道题的母题:给定一个字符串,求不相同的子串的个数(spoj694,spoj705),先讲一下这个母题:算法分析:每个子串一定是某个后缀的前缀,那么原问题等价与求所有后缀之间的不相同的前缀的个数。如果所有的后缀按照suffix(sa[1]),suffix(sa[2]),suffix(sa[3])…suffix(sa[n])的顺序计算,不难发现,对于每一次新加进来的后缀suffix(sa[k]),它将产生n-sa[k]+1个新的前缀。但是其中有height[k]个是和前面的字符串的前缀是相同的。所以suf 阅读全文
posted @ 2013-03-26 21:35 _sunshine 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 感觉这道题用并查集用的挺巧妙的~链接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1041题意:1,2,3,4,5,6……n块巧克力(不超过10^6),m次询问,每次询问问(a,b)之间还有几个巧克力,有几个吃掉几个。例如样例:sample intput6 41 24 41 31 4sample output2110View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include <iost 阅读全文
posted @ 2013-03-26 21:22 _sunshine 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 纪念一下第五场腾讯马拉松进了前300,没进复赛,你懂得~AC率不到2%的原因竟然是double,怕溢出用long long,__int64都是WA~变成double就AC了~View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include <iostream> 4 #include <cstring> 5 #include <math.h> 6 using namespace std; 7 int main(){ 8 int T,n; 9 double k1,k2,k,a,su 阅读全文
posted @ 2013-03-26 21:02 _sunshine 阅读(242) 评论(0) 推荐(0) 编辑