8月19日CCPC——A Secret(未解决)
来源:互联网 发布:阿里云邮箱的pc客户端 编辑:程序博客网 时间:2024/05/18 18:45
Problem DescriptionToday is the birthday of SF,so VS gives two strings S1,S2 to SF as a present,which have a big secret.SF is interested in this secret and ask VS how to get it.There are the things that VS tell: Suffix(S2,i) = S2[i...len].Ni is the times that Suffix(S2,i) occurs in S1 and Li is the length of Suffix(S2,i).Then the secret is the sum of the product of Ni and Li. Now SF wants you to help him find the secret.The answer may be very large, so the answer should mod 1000000007. InputInput contains multiple cases. The first line contains an integer T,the number of cases.Then following T cases. Each test case contains two lines.The first line contains a string S1.The second line contains a string S2. 1<=T<=10.1<=|S1|,|S2|<=1e6.S1 and S2 only consist of lowercase ,uppercase letter. OutputFor each test case,output a single line containing a integer,the answer of test case. The answer may be very large, so the answer should mod 1e9+7. Sample Input2aaaaaaaabababababa Sample Output1319Hintcase 2: Suffix(S2,1) = "aba",Suffix(S2,2) = "ba",Suffix(S2,3) = "a".N1 = 3,N2 = 3,N3 = 4.L1 = 3,L2 = 2,L3 = 1.ans = (3*3+3*2+4*1)%1000000007.
这道题就是找第二个字符串在第一个字符串中的子集的个数。
aaaaa
aa
4*2+5*1=13
一开始运用strstr函数,测试用例可以,但提交超时。
最后确认为用KMP来做,未果。
欢迎大神指点,欢迎大神提供答案和思路。
阅读全文
0 0
- 8月19日CCPC——A Secret(未解决)
- 8月19日CCPC——Vertex Cover(未解决)
- 8月19日CCPC——Party(未解决)
- 8月19号CCPC——Palindrome Function(未解决)
- 8月19号CCPC——The Karting(未解决)
- 8月19日CCPC——Friend-Graph
- 8月19号CCPC——CaoHaha's staff(未解答)
- 8月19号CCPC——The Designer(未解答)
- 8月19号CCPC——Graph Of Zhuper(未解答)
- HDU 6153-A Secret(kmp&&ccpc)
- HDU-6153---A Secret (扩展kmp)(2017ccpc网络赛)
- ccpc 2017 网络赛 1004 A Secret (扩展kmp)【模板】
- A Secret 2017 CCPC 网络选拔赛 hdu 6153
- 【KMP+优化】HDU 6153/CCPC 1003 A Secret
- HDU 6153 A Secret CCPC网络赛,KMP拓展应用
- 会议记录(7月26日——8月25日)
- 8月19日
- ACM训练日记—8月19日
- PHP新手必看
- 更新eclipse中的maven插件
- 深入了解Windows句柄到底是什么
- wireshark报没有可以捕获的接口
- Linux下定位内存泄漏-查看内存空间
- 8月19日CCPC——A Secret(未解决)
- BZOJ 2527: [Poi2011]Meteors 整体二分 树状数组
- javase-语句
- VC++出现无法解析的外部符号的几种情况
- GO语言函数
- jar包和war包的区别
- HDFS
- oracle中怎么用SQL语句获取指定数据库中的所有表名
- 有关哈希表