There's a relatively easy way to solve problems of this nature. You determine the contribution made if the only contributor is the one that contributes the least.
A chicken has the least number of feet, so 24 chickens will contribute 48 feet.
Now, you consider the change in contribution made by substituting a larger contributor. Each pig that replaces a chicken will add 2 feet to the total.
Consider how many feet need to be added, and thus how many larger contributors are needed. 80 -48 = 32 feet need to be added, so 32/2 = 16 of the animals need to be pigs.
There are 16 pigs and 8 chickens.