report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
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 ```
Introduction to Prefix sum
Prefix sum
Maximum subarray sum
Balance substring
Divisible by d
Subarray sum
Game on array
2D prefix sum
Stair query
Maximum sum subarray 2
Average
Ratio Substrings
Maximum submatrix sum
Maximum subarray sum 3
Manhattan distance
Minimum distance
Topic
Prefix sum
Rating 1000
Solution (1) Solution