For these kinds of problems, get a common denominator. Put everything over that common denominator and add or subtract the terms in the numerator. Combine like terms. See images.
For this question you would divide $8.52 by 36 pencils to get about $0.24 per pencil for brand A rounded to the nearest cent. Then divide $9.98 by 48 pencils to get about $0.21 per pencil for brand B rounded to the nearest cent.