We study S-wave resonance contributions to the B 0 (s) → J/ψπ + π − and Bs → π + π − µ + µ − decays in the perturbative QCD framework by introducing two-hadron distribution amplitudes for final states. The Breit−Wigner formula for the f0(500), f0(1500), and f0 (1790) resonances and the Flatté model for the f0(980) resonance are adopted to parametrize the timelike scalar form factors in the two-pion distribution amplitudes, which include both resonant and nonresonant contributions. The resultant branching fraction and differential branching fraction in the pion-pair invariant mass for each resonance channel are consistent with experimental data. The determined S-wave two-pion distribution amplitudes, containing the information of both resonant and nonresonant rescattering phases, can be employed to predict direct CP asymmetries of other three-body hadronic B meson decays in various localized regions of two-pion phase space.