Determining elemental compositions from exact masses and relative abundances of ions