Expected number of objects of type A I will get if I take $K$ objects. Suppose I have:


*

*$x$ objects of type A.

*$y$ objects of type B.
Now I take $K$ objects randomly, taking each object with the same probability. What is the expected number of objects I will get of type A?
I can solve it using dynamic programming but its too costly for big values.
 A: This is hypergeometric distribution. If $K$ is the number of type $A$ items and $x+y=n$, use this:
$$
P(K=0)=\frac{\binom{y}{k}}{\binom{n}{k}}\\
P(K=1)=\frac{\binom{x}{1}\binom{y}{k-1}}{\binom{n}{k}}\\
\ldots\\
P(K=k)=\frac{\binom{x}{k}}{\binom{n}{k}}
$$
This assumes $k \leq x$.
A: I take it we have a total of $x+y$ objects, and we take a sample of $K$ objects, without replacement. Then the number of Type A objects we get has hypergeometric distribution. If you like, you probably find everything you need about the hypergeometric distribution by going through parts of this Wikipedia article.
In particular, you will find that the expected number of Type A objects is $K\dfrac{x}{x+y}$.
Remark: The proof is quick, if one has some background in random variables. We can imagine that the objects are removed and examined one at a time. Let random variable $W_i$ be equal to $1$ if the $i$-th object chosen is of Type A, ane let $W_i=0$ otherwise. Then the number of Type A objects selected is equal to $W_1+W_2+\cdots +W_K$. By the linearity of expectation, we have 
$$E(W_1+W_2+\cdots +W_K)=E(W_1)+E(W_2)+\cdots +E(W_K)/$$
Each $W_i$ is $1$ with probability $\frac{x}{x+y}$, so has expectation $\frac{x}{x+y}$. It follows that the sum has expectation $K\frac{x}{x+y}$.
