How many solutions in integers are there to the equation $_1+_2+⋯+_{500}=340$ , such that for every $: 0≤_≤1$? How many solutions in integers are there to the equation $_1+_2+⋯+_{500}=340$ , such that for every $: 0≤_≤1$?
At first I tried using the inclusion exclusion principle, as in: 340 balls spreaded into 500 compartments s.t every compartment can get zero or one balls. 
Not sure how to proceed from here..
 A: HINT:  you have 500 variables.  The ones that are 0 don't contribute to the sum.  So you have to choose which 340 of them are equal to 1.  How many ways are there to do this?
A: The counting generating function for the combinatorial configuration is
$$
(1+z)(1+z) \cdots (1+z)=(1+z)^{500}.
$$
Thus the number of solutions are 
$$
[z^{340}](1+z)^{500}=\binom{500}{340}.
$$
A: Because each $x_i$ where $0 \leq i \leq 500$ is either a $0$ or a $1$, You could similarly ask:
How many ways are there to generate a binary string with a length of 500 which contains exactly 340 $1$s and 160 $0$s.
There is a total of ${500}\choose{340}$ to place the $1$s in the binary string, and the rest of the $0$s go into the remaining places, which is the answer to your question.
A: Well, heh-heh.  Of $X_i \in \mathbb Z$ and if $0 \le X_i \le 1$ then.... $X_i = 0$ or $1$.  So all summands are either $0$ or $1$.
If there are $a$ summands that are $0$ and $b$ summands that are $1$ then the sum is $0*a + 1*b = 340$ so $b = 340$ and there are $340$ ones and the rest are $0$s.
which brings us to Michael Seifert's charming hint.
