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来做,未果。

欢迎大神指点,欢迎大神提供答案和思路。

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 月经推迟11天了怎么办孕测棒单杠 小孩子不小心把蜡笔吃一点怎么办 线切割切割的工件表面有条纹怎么办 苹果手机不能用流量更新吃鸡怎么办 吃鸡更新成雨林如果内存不够怎么办 绝地求生刺激战场背包满了怎么办 绝地求生刺激战场模拟器满了怎么办 绝地求生刺激战场电脑版满了怎么办 绝地求生手游模拟器注册上限怎么办 绝地求生电脑模拟器已达上限怎么办 三星s5锁屏密码忘了怎么办 字画装框的时候起褶皱怎么办 指甲油抹在手上不在指甲上怎么办 我把油画的布割破了怎么办 胜战本领怎么看、走上战场怎么办 胜战本领怎么看 走上战场怎么办 数码相机拍出的相片亮度太亮怎么办 国考照片错了怎么办招生办能改吗 国考英语准考证名字错了怎么办 玻尿酸打鼻子双眼间距好怪怎么办 喝咖啡后胃不舒服想吐怎么办 分期付款买的车不想还款了怎么办 考试时打小抄被同学发现怎么办 生完二胎计生办强制要求上环怎么办 没办二代身份证户口被注销怎么办 川航特价儿童票名字写错怎么办 川航机票名字错一个字怎么办 买飞机票名字打错了一个字怎么办 坐飞机耳朵聋了下飞机还痛怎么办 小孩咳嗽两个月了还不好怎么办 生完小孩肚子瘦不下来怎么办 胆子小一个人在家里都害怕怎么办 怀了双胞胎两个宝宝很挤怎么办 飞机无人陪护如果接机延误该怎么办 过年要坐火车回家 狗狗怎么办 一岁八个月宝宝小腿弯怎么办 2岁宝不愿意坐马桶拉屎怎么办 宝宝两岁多肺炎出院还老咳嗽怎么办 去外国机场买机票不会说外语怎么办 坐飞机不能带的物品办理托运怎么办 深圳外地户口儿童要办身份证怎么办