Okay usually pies are cut with 8 pieces.
You're going to take 5(amount of pies) * 8(slices per pie) to get total of 40.
this is how many pieces. You're going to take 40 and divide by 8 to see how many pieces an individual can have. The answer is 5.
this makes sense because 5*8 is 40 and you divide 8, so you'll get 5. This wouldn't be the case though if the pie was cut only 4 pieces or 7 pieces. Most likely your teacher wants you to assume each pie has 8 pieces