import java.util.Scanner; public class ali0901 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String s1 = sc.nextLine(); String[] t=s1.split(" "); int n=Integer.parseInt(t[0]); int m=Integer.parseInt(t[1]); String s=sc.nextLine(); String y=sc.nextLine(); int res=0; char []arr=s.toCharArray(); char []acc=y.toCharArray(); //其中前面要连续 for(int i=0;i<arr.length;i++){ a:for(int j=i;j<arr.length;j++){ //单字符 if(i==j){ if(y.indexOf(s.charAt(i))!=-1){ res++; } //子字符串 }else{ int a=i,b=j; int fro=-1; int tmp; int k=0; while(a<=b){ tmp=y.indexOf(s.charAt(a),k); //todo:要找下一个字符 if(tmp!=-1&&tmp>fro){ fro=tmp; k=tmp+1; a++; } else continue a; } res++; } } } System.out.println(res); } }
点赞 评论

相关推荐

05-07 17:58
门头沟学院 Java
wuwuwuoow:1.简历字体有些怪怪的,用啥写的? 2.Redis 一主二从为什么能解决双写一致性? 3.乐观锁指的是 SQL 层面的库存判断?比如 stock > 0。个人认为这种不算乐观锁,更像是乐观锁的思想,写 SQL 避免不了悲观锁的 4.奖项证书如果不是 ACM,说实话没什么必要写 5.逻辑过期时间为什么能解决缓存击穿问题?逻辑过期指的是什么 其实也没什么多大要改的。海投吧
简历中的项目经历要怎么写
点赞 评论 收藏
分享
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务