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?

(In reply to

answer by K Sengupta)

At the outset, 100 pigs cost 800 dollars, so that each pig cost 8

dollars.

Let the respective number of pigs, chickens and cows that the

individual can buy be x, y and z.

Then, by the given conditions:

x+y+z = 100 ..........(I)

8x+ y+ 80z = 800......(II)

with the restriction x< = 99.

Then, subtracting (I) from (II), we must have:

7x+79z = 700 .......(III)

or, 79z (Mod 7) = 0

Since gcd (7,79) = 1, we must have:

z (mod 7) = 0

If z=0, then from (II), we have x = 100, which is a contradiction.

If z>=14, then the lhs of (iii) >= 79*14 = 1106 > 700, which leads to a contradiction.

Thus, z = 7 giving x = (700 - 7*79)/7 = 21

Accordingly, y = 100 - (21+7) = 72