You are sent to the market by your father with 800 dollars, and told to buy 100 animals. When you arrive at the market, you find out that pigs cost 8 dollars each, so it would be easy to follow your father's instructions.

However, you see that there are only 99 pigs for sale. The only other animals there are chickens for 1 dollar each, and cows for 80 dollars each.

If there are enough chickens and cows for you to buy as many as you wanted, how can you end up buying 100 animals using exactly 800 dollars?

Let's call C the number of chickens, P the number of pigs, and M the number of cows -- M comes from "Mooooh!" ;-)

From 8P+C+80M=800 it follows that the number of chickens must be a multiple of 8, so C=8C', and now we have 8P+8C'+80M=800, or P+C'+10M=100.

It now follows that P+C' must be a multiple of 10, so P+C'=10K, and now we have 10K+10M=100, so K+M=10.

Let's consider the number of animals: P+C+M=100, so P+8C'+M=100. But P+C'=10K, so we get 10K+7C'+M=100. Now, since K+M=10, 10+9K+7C'=100, or 9K+7C'=90.

From the latter it follows that C' must be a multiple of 9, so C'=9C". Since C=8C', therefore C=72C". As there were 100 animals, C" can only be 0 or 1; if the former, we'd need 100 pigs, so it must be the latter, and we get C=72 chickens.

As P+C'=10K, P can be 1, 11 or 21 (31 would be too much), and K would be 1, 2, or 3, so M would be 9, 8 or 7 -- the latter option works out, and we have therefore 21 pigs and 7 cows.∞