A Monte Carlo method for calculating strength functions in many-fermion systems