Prof. Peter runs a lottery for his class with an unusual rule. He first announces a small positive integer M. Each of the N students then secretly writes one integer from 1 to M on a slip of paper and folds the slip. After everyone has chosen, all slips are opened at once. Among the numbers that exactly one student wrote, the student who wrote the smallest one wins. If no number was written by exactly one student, there is no winner.
For example, with three students, if two of them write 2 and the third writes 5, then the student who wrote 5 wins.
Now suppose every student follows the same randomized strategy, so each student picks number k with probability pk. The strategy is optimal if, when everyone follows it, no single student can raise his own winning probability by switching to a different strategy.
Given N and M, find the optimal strategy, that is, the probability of picking each number from 1 to M. The optimal strategy is unique in the given range.