You have to buy 100 animals with $100, so at the end, your average payment per animal is $1.
Every time you buy a cat, you are paying exactly the average price. But every dog represents an "overpayment" of $14 above the average, while every hamster represents an "underpayment" of 75 cents. If the average at the end is to be $1, then the overpayments must cancel the underpayments.
In other words, D * 14 - H * 0.75 = 0
Since D and H must be integers, we can multiply through by 4 and rearrange to get 56 * D = 3 * H.
Since 56 and 3 have no common factors, the only way this equation can be true is if D = 3 * N, and H = 56 * N, where N is an integer. The lowest value of N we can take is 1. Therefore, we want to buy 3 dogs and 56 hamsters.
That gives us a perfect average, but not enough animals. We buy 41 cats, without hurting our average, and now we have the following bill:
3 dogs at $15.00 = $45 41 cats at $1.00 = $41 56 hamsters at $0.25 = $14 ------------ ---- 100 animals $100
Back to The Cat Dog Hamster Puzzle;