Step 1: Understanding the Concept:
Identify the elements from the configurations, then balance the charges.
Step 2: Identify:
A: \(1s^22s^22p^63s^23p^64s^2\) has \(20\) electrons, so it is calcium. It loses \(2\) electrons to give \(\text{A}^{2+}\).
B: \(1s^22s^22p^63s^23p^5\) has \(17\) electrons, so it is chlorine. It gains \(1\) electron to give \(\text{B}^-\).
Step 3: Balance charges:
One \(\text{A}^{2+}\) needs two \(\text{B}^-\), so the formula is \(\text{AB}_2\) (like \(\text{CaCl}_2\)).
The other formulae do not balance: \(\text{A}_2\text{B}\) gives \(+4\) and \(-1\), \(\text{AB}_5\) gives \(+2\) and \(-5\), \(\text{A}_5\text{B}_2\) gives \(+10\) and \(-2\).
Final Answer:
The formula of the ionic compound is \(\text{AB}_2\), option (B).
\[ \boxed{\text{AB}_2} \]