Ion-mediated interaction is critical to the structure and stability of nucleic acids. Recent experiments suggest that the multivalent ion-induced aggregation of double-stranded (ds) RNAs and DNAs may strongly depend on the topological nature of helices, while there is still lack of an understanding on the relevant ion-mediated interactions at atomistic level. In this work, we have directly calculated the potentials of mean force (PMF) between two dsRNAs and between two dsDNAs in Co(NH3)63+ (Co-Hex) solutions by the atomistic molecular dynamics simulations. Our calculations show that at low [Co-Hex], the PMFs between B-DNAs and between A-RNAs are both (strongly) repulsive. However, at high [Co-Hex], the PMF between B-DNAs is strongly attractive, while those between A-RNAs and between A-DNAs are still (weakly) repulsive. The microscopic analyses show that for A-form helices, Co-Hex would become ‘internal binding’ into the deep major groove and consequently cannot form the evident ion-bridge between adjacent helices, while for B-form helices without deep grooves, Co-Hex would exhibit ‘external binding’ to strongly bridge adjacent helices. In addition, our further calculations show that, the PMF between A-RNAs could become strongly attractive either at very high [Co-Hex] or when the bottom of deep major groove is fixed with a layer of water.