A painter is going to paint a room shaped like a cube, with square walls that are 20 feet on each side. a gollon of paint can be used to cover 400 square feet. How many gallons of paint should the painter buy if he is going to paint the four walls of the room?

The area of each wall is given by the equation A = s^2, where s represents the length of the side of the square wall.

So, the area of each wall is A = 20^2 = 400 square feet.

Since there are four walls, the total area to be painted is 4A = 4 * 400 = 1600 square feet.

A gallon of paint covers 400 square feet, so the painter needs 1600/400 = <<1600/400=4>>4 gallons of paint. Answer: \boxed{4}.