Tap here to switch tabs
Problem
Submissions

Problem: Count K-Reducible Numbers Less Than N

Count K-Reducible Numbers Less Than N asks you to count positive integers below a binary number that reach one within a set number of bit-counting operations, returning the result modulo a large prime.

Statement

You are given a binary string s representing a positive integer n in its binary form, and an integer k.

In a single operation, an integer is replaced by the count of set bits in its binary representation. An integer is considered kk reducible if it can be reduced to 11 in at most kk operations.

Return the count of positive integers strictly less than n that are kk reducible. Since the answer may be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq s.length ≤800\leq 800

  • s has no leading zeros.

  • s consists only of the characters $'0'$ and $'1'$.

  • 1≤1 \leq k ≤5\leq 5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count K-Reducible Numbers Less Than N

Count K-Reducible Numbers Less Than N asks you to count positive integers below a binary number that reach one within a set number of bit-counting operations, returning the result modulo a large prime.

Statement

You are given a binary string s representing a positive integer n in its binary form, and an integer k.

In a single operation, an integer is replaced by the count of set bits in its binary representation. An integer is considered kk reducible if it can be reduced to 11 in at most kk operations.

Return the count of positive integers strictly less than n that are kk reducible. Since the answer may be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq s.length ≤800\leq 800

  • s has no leading zeros.

  • s consists only of the characters $'0'$ and $'1'$.

  • 1≤1 \leq k ≤5\leq 5