In Graham, Knuth & Patashnki's "Concrete Mathematics" in chapter 7 shows how to use generating functions to solve problems exactly like this. Their example uses pennies, nickels, dimes, quarters and half dollars but the same steps should apply to your problem.
