Dynamic Programming21 sections · 916 units
Open in Course

Bit Problem - Problem Statement

CSES 1654

Given nn integers, compute three counts for each element xx:

1.1. How many elements yy satisfy xy=xx \mid y = x? (OR equals xx)

2.2. How many elements yy satisfy xy=xx \land y = x? (AND equals xx)

3.3. How many elements yy satisfy xy0x \land y \neq 0? (AND is non-zero) Constraints: n2×105n \leq 2 \times 10^5, values up to 10610^6. The brute force O(n2)O(n^2) is too slow. Each query type needs a different SOS DP formulation.