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?
21 pigs, 72 chickens, 7 cows
Explanation
Let P be the number of pigs, C be the number of chickens, and W be the number of cows.
P+C+W=100
800 = 8P+C+80W (where P<=99)
C=100PW
800=8P+100PW+80W
7P+79W=700
7P=70079W
P=(70079W)/7
So the first value of 70079W that is a multiple of 7 will do the trick. e.g. W=7

Posted by Penny
on 20040219 09:36:07 