With 300 dollars one will have to buy total 30 items. If price of a exercise book is 30 dollars, price of pen is 24 dollars and price of a pencil is 6 dollars, and if that person is bound to buy at least one of each item, how many exercise books, how many pens and how many pencils he needs to buy so that summation of numbers of these items equals to 30?

number of books ---- x

number of pens ----- y
number of pencils --- 30-x-y
(we know x and y must be whole numbers)

30x + 24y + 6(30-x-y) = 300
30x + 24y + 180 - 6x - 6y = 300
24x + 18y = 120
4x + 3y = 20
y = (20 - 4x)/3

try x = 1 , 2, 3, or 4
for y to be a whole number, x has to be 2

so x = 2 , y = 4, and 30-x-y = 24

He will buy 2 books, 4 pens and 24 pencils

check:
2+4+24 = 30 ? , YES
30(2) + 24(4) + 6(24) = 300 ? , YES