Numerical simulations of the accretion of Uranus and Neptune