If $0 \leq a \leq A$, $0 \leq b \leq B$, $0 \leq c \leq C$, $0 \leq N$, $(a+b+c) \leq N$. What is the total number of combinations satisfying the inequality without using 3 nested loops?
Asked
Active
Viewed 85 times
2
-
what's a loop ? – Paolo Leonetti Feb 15 '15 at 09:34
-
You can calculate this by inclusion-exclusion on how many of the inequalities $a\le A$, $b\le B$, $c\le C$ are violated. For example, the number of $a+b+c\le N$ with $a>A$ (and $b$, $c$ arbitrary) is the same as the number of $a'+b+c\le N-A-1$. – Greg Martin Feb 15 '15 at 09:35