子串简写 代码 k=int(input()) s,c1,c2=input().split() pre=[0]*len(s) ans=0 for i in range(len(s)): pre[i]=pre[i-1] if c1==s[i]: pre[i]+=1 elif c2==s[i] and i+1-k>=0: ans+=pre[i-k+1] print(ans)