Tap here to switch tabs
Problem
Submissions

Problem: Number of Good Binary Strings

med
30 min
Try to solve the Number of Good Binary Strings problem.

Statement

You are given four integers minLength, maxLength, oneGroup, and zeroGroup.

A binary string is defined as good if:

  • Its length is at least minLength and at most maxLength.

  • The length of each contiguous block of '1's is a multiple of oneGroup.

  • The length of each contiguous block of '0's is a multiple of zeroGroup.

Return the total number of good binary strings. Since the answer can be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq minLength ≤\leq maxLength ≤105\leq 10^5

  • 1≤1 \leq oneGroup, zeroGroup ≤\leq maxLength

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Good Binary Strings

med
30 min
Try to solve the Number of Good Binary Strings problem.

Statement

You are given four integers minLength, maxLength, oneGroup, and zeroGroup.

A binary string is defined as good if:

  • Its length is at least minLength and at most maxLength.

  • The length of each contiguous block of '1's is a multiple of oneGroup.

  • The length of each contiguous block of '0's is a multiple of zeroGroup.

Return the total number of good binary strings. Since the answer can be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq minLength ≤\leq maxLength ≤105\leq 10^5

  • 1≤1 \leq oneGroup, zeroGroup ≤\leq maxLength