Ensemble Gomgom
InterviewTime limit1sMemory limit1024 MB
Given N members who each pick one of K notes with equal probability, find the expected number of pairs that play the same note.
- Level
Easy3 of 10
- Topics
- Probability, Math
- Solved
- No attempts yet
Problem
Gomgom plays the xylophone very well.
When Gomgom's mallet touches the keys, everyone nearby pays attention to the clear sound of the xylophone.

Gomgom formed an ensemble to make people happy with this talent. The ensemble has many Gomgoms, and each Gomgom takes one note and plays it following the score.
Gomgom's xylophones sound clearer when several Gomgoms play the same note together. So they decided to group the Gomgoms who play the same note.
After a successful performance, each member of a group has a meal alone with every other member of the group, one at a time, to get to know each other.
The ensemble leader, Gomgom, pays for these meals, so the leader must know the amount in advance to prepare the money before the show.
The score has not been decided yet, so the number of members in each group is unknown, and the exact cost cannot be calculated.
Therefore, the leader wants to find the expected number of meals and prepare money for that amount.
Assume that the note each Gomgom plays is chosen with equal probability from the available notes.
Help the leader so that no member goes without a meal!

Input
The first line contains the number of ensemble members () and the number of notes () that Gomgom can play, in that order.
Output
Print the expected number of meals. An absolute or relative error of up to is allowed.