Production of hadrons at large transverse momentum in 200-, 300-, and 400-GeVppandp-nucleus collisions