Ratio Substrings - MarisaOJ: Marisa Online Judge

Ratio Substrings

Time limit: 1000 ms
Memory limit: 256 MB
Given a binary string of length $n$, count the number of consecutive substrings with a ratio of $0$'s to $1$'s equal to $\frac{x}{y}$. ### Input - The first line consists of two integers $x$ and $y$. - The second line consists of a binary string of length $n$. ### Output - Print the number of consecutive substrings that satisfy the condition. ### Constraints - $1 \le x, y \le n \le 10^5$. ### Example Input: ``` 1 2 1010 ``` Output: ``` 1 ```