#P15111. 群星

    ID: 16810 远端评测题 1500ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划 DPSpecial JudgeO2优化动态规划优化矩阵加速期望

群星

Background

You and a group of friends are slacking off together。

Problem Description

You open Stellaris and start a new game, turning on spectator mode。The game automatically generates nn civilizations, where the initial power rank of the ii-th civilization is ii。You decide to watch the game in the following way。

The game is divided into kk centuries。In the ii-th century, there will be aia_i wars。Each war randomly selects one pair among the (n2){n \choose 2} pairs of different civilizations, and swaps their ranks。At the beginning of each century, everyone performs one civilization-picking step。Specifically, since you are the host, you may first decide whether to pick a civilization in this round。If yes, you choose any civilization that has not been chosen yet; otherwise, exactly one friend will choose the currently highest-ranked civilization among those that have not been chosen yet。After a civilization is chosen, it cannot be changed (that is, you can only choose at the beginning of a century)。

After discussing the rules, you become very interested in the optimal strategy for picking civilizations。So you plan to write a program to compute, for all ii, if you pick a civilization at the beginning of the ii-th century, what is the minimum possible expected final rank of the civilization you pick。Since you do not like taking modulo, you only need to output the answer rounded to five decimal places (printing more digits is also acceptable)。

Input Format

The first line contains two integers n,kn, k

The second line contains kk integers, where the ii-th integer represents aia_i

Output Format

Output kk lines, one per line as described in the statement。

3 3
1 0 0
2.00000
1.33333
2.66667

Hint

This problem uses bundled testdata and Special Judge. Your answer is accepted as long as the difference from the standard answer does not exceed 10510^{-5}

For 20%20\% of the testdata, n,k,ai3n, k, a_i \leq 3

For 60%60\% of the testdata, n,k50n, k \leq 50ai10000\sum a_i \leq 10000

For 100%100\% of the testdata, n50n \leq 50k50k \leq 500ai1070 \leq a_i \leq 10^7knk \leq n

Translated by ChatGPT 5