Let 'p' and 'c' denote the number of pigs and the number of chickens, respectively.
Given that there are 30 heads, and we know that each animal has a single head,
[tex]\begin{gathered} p+q=30 \\ q=30-p \end{gathered}[/tex]Knowing that a pig has 4 legs, and a chicken has 2 legs. It is given that the total number of legs is 82,
[tex]\begin{gathered} 4p+2q=82 \\ 2p+q=41 \end{gathered}[/tex]Substitute the value of 'q' from first equation into the second equation,
[tex]\begin{gathered} 2p+(30-p)=41 \\ 2p-p=41-30 \\ p=11 \end{gathered}[/tex]Substitute the value in the first equation,
[tex]\begin{gathered} q=30-11 \\ q=19 \end{gathered}[/tex]Thus, there are 11 pigs and 19 chickens.