0

Given the following linear equation in $x_1, x_2, \dots, x_n \in \mathbb positive\ integers\ including\ 0 $

$$C_1 x_1 + C_2 x_2 + C_3 x_3 + \dots + C_n x_n = 0$$

where $C_1, C_2, \dots, C_n \in \mathbb Z$ $$L \leq x_1,x_2,\dots,x_n \leq R$$

L and R are positive integers including 0

how can I find the number of solutions?

1 Answers1

0

Recursive approach leads to solution with $\mathcal{O}(n \max(|L|,|R|))$ by reducing this to problem of selecting sums from multiset $\{C_1,C_1,\dots,C_n\}$ with appropriate number of repetitions.

You are interested in this article for implementations:

Wiki: Subset sum problem

Radost
  • 1,802