Layout optimization of the beam spot locations scanned by electromagnets in particle beam therapy