In general
#color(white)("XXX")(x^3-a^3)# can be factored as: #(x-1)(x^2+ax+a^2)#
Replacing #a=1# gives the result in the "Answer"
#underline(" X | " x^2 color(white)("XX") +axcolor(white)("XXXXX") +a^2)#
#x color(white)("X")" | "color(white)("XX") x^3 color(white)("XX") +cancel(ax^2) color(white)("XX") +cancel(a^2x)#
#-a" | " cancel(-ax^2) color(white)("XX") cancel(a^2x)color(white)("XXXX") -a^2#