Suppose we have N people sitting in a long one sided table.
Every person not on the edge of the table, is talking with the person to his right and to the left and getting acquainted with him.
The first and last person on the table are getting acquainted with their person to the right and left respectively.
After their talks are done, how many ways are there to choose K guests such that there are M pairs of familiar people:
I need some help on this one. I d like to solve but it seems so tough ...
Ok, this is wandering into more stackoverflow territory than math.stackexchange, but so it goes. This is too long for a comment.
Let $f(n,k,m)$ be the number of ways of choosing $k$ guests out of $n$ such that $m$ pairs of them are familiar. To make things simpler, let us label the guests $a_1,a_2,\dots,a_n$.
Now let us look at what happens to $a_n$. There are $f(n-1,k,m)$ ways of choosing $k$ guests other than $a_n$ so that there are $m$ pairs of them are familiar. Now if $a_n$ is one of the chosen members, but $a_{n-1}$ is not, then there are $f(n-2,k-1,m)$ ways of choosing the remaining members. If $a_n$ and $a_{n-1}$ are both chosen, but $a_{n-2}$ is not then there are $f(n-3,k-2,m-1)$ ways of choosing the remainder. Similarly if $a_{n-i}$ to $a_n$ are all chosen but $a_{n-i-1}$ is not, then there are $f(n-i-2, k-i-1, m-i)$ ways of choosing the remainder. Putting these all together, we get $$f(n,k,m) = f(n-1,k,m) +\sum_{i=0}^m f(n-i-2,k-i-1,m-i).$$
Simple boundary conditions are $f(n,k,m)=0$ if $k>n$ and $f(n,k,m)=0$ if $m\ge k$ unless $m=k=0$ and $f(n,k,m)=0$ if $m<0$ and $f(n,0,0)=1$ and $f(n,n,m-1) = 1$.
This can be improved, but I'll let you work out the details.