Иван Панфилов
Ученик
(103)
1 месяц назад
def count_harmonic_substrings(s):
n = len(s)
count = 0
for i in range(n):
zeros = 0
ones = 0
for j in range(i, n):
if s[j] == '0':
zeros += 1
else:
ones += 1
if zeros % 2 == 0 and ones % 2 == 0:
count += 1
return count
n = int(input().strip())
s = input().strip()
print(count_harmonic_substrings(s))