Advertisement
Egor_1425

Untitled

Mar 17th, 2024
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | None | 0 0
  1. k = int(input())
  2. s = input()
  3. ex = ans = 0
  4. for i in range(len(s) - k - 1, -1, -1):
  5.     if s[i] == s[i + k]:
  6.         ex += 1
  7.     else:
  8.         ex = 0
  9.     ans += ex
  10.  
  11. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement