There are $p$ students and $q$ books where $q>p$ and all books are different, but each student will get a minimum of $1$ book and a maximum of $(p – 1)$ books. Find the total number of ways of distributing the books?
My thought was
Total - invalid cases
total $=p^q$
invalid
- case 1 -when all to one student - $p$ ways
- case 2- when all books are divided between $2$ students $(2<p)$, $q^2$ ways
- case 3- when all books are divided between $3$ students $(3<p)$, $q^3$ ways and so on up to when all are divided between $ p-1$ students.
Above cases are for satisfying the criteria of min 1 book to each student.
Now for maximum $p-1$ books (when each student have at least one) I am having confusion as to the assumptions to take and all.
This is a direct application of the stars-and-bars technique.