CF601C.Kleofáš and the n-thlon

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Kleofáš is participating in an n-thlon - a tournament consisting of n different competitions in n different disciplines (numbered 1 through n). There are m participants in the n-thlon and each of them participates in all competitions.

In each of these n competitions, the participants are given ranks from 1 to m in such a way that no two participants are given the same rank - in other words, the ranks in each competition form a permutation of numbers from 1 to m. The score of a participant in a competition is equal to his/her rank in it.

The overall score of each participant is computed as the sum of that participant's scores in all competitions.

The overall rank of each participant is equal to 1 + k, where k is the number of participants with strictly smaller overall score.

The n-thlon is over now, but the results haven't been published yet. Kleofáš still remembers his ranks in each particular competition; however, he doesn't remember anything about how well the other participants did. Therefore, Kleofáš would like to know his expected overall rank.

All competitors are equally good at each discipline, so all rankings (permutations of ranks of everyone except Kleofáš) in each competition are equiprobable.

克莱奥法什正在参加一项“n项全能”比赛——该赛事包含 nn 个不同学科(编号为 11 至 nn)的 nn 场独立竞赛。共有 mm 名参赛者参加这项 n 项全能比赛,且每人参与全部 nn 场竞赛。

在每场竞赛中,所有 mm 名参赛者被赋予从 11 到 mm 的互不相同的名次(即:每场竞赛的名次构成 11 到 mm 的一个排列)。一名参赛者在某场竞赛中的得分即为其在该场竞赛中的名次。

每位参赛者的总分定义为他在全部 nn 场竞赛中得分之和。

每位参赛者的总排名定义为 1+k1 + k,其中 kk 是总分严格小于该参赛者总分的参赛者人数。

目前 n 项全能比赛已经结束,但结果尚未公布。克莱奥法什仍记得自己在每场竞赛中的具体名次;然而,他对其他参赛者在各场竞赛中的表现一无所知。因此,克莱奥法什希望知道自己的期望总排名。

所有参赛者在每一学科中实力完全相同,因此在每场竞赛中,除克莱奥法什外其余 m−1m-1 人的名次排列(即所有可能的 (m−1)!(m-1)! 种排列)是等概率出现的。

输入格式

The first line of the input contains two space-separated integers n (1 ≤ n ≤ 100) and m (1 ≤ m ≤ 1000) — the number of competitions and the number of participants respectively.

Then, n lines follow. The i-th of them contains one integer x__i (1 ≤ x__i ≤ m) — the rank of Kleofáš in the i-th competition.

输入的第一行包含两个用空格分隔的整数 nn(1 ≤ n ≤ 1001 ≤ n ≤ 100)和 mm(1 ≤ m ≤ 10001 ≤ m ≤ 1000)——分别表示比赛场数和参赛者人数。

接下来有 nn 行。其中第 ii 行包含一个整数 xix_i(1 ≤ xi ≤ m1 ≤ x_i ≤ m)——表示 Kleofáš 在第 ii 场比赛中的名次。

输出格式

Output a single real number – the expected overall rank of Kleofáš. Your answer will be considered correct if its relative or absolute error doesn't exceed 10 - 9.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

输出一个实数——Kleofáš 的期望总排名。若你的答案的相对误差或绝对误差不超过 10−910^{-9},则视为正确。

具体而言:假设你的答案为 aa,评测组的标准答案为 bb。当满足 时,评测程序将判定你的答案正确。

输入输出样例

  • 输入#1

    4 10
    2
    1
    2
    1

    输出#1

    1.0000000000000000
  • 输入#2

    5 5
    1
    2
    3
    4
    5

    输出#2

    2.7500000000000000
  • 输入#3

    3 6
    2
    4
    2

    输出#3

    1.6799999999999999

说明/提示

In the first sample, Kleofáš has overall score 6. Nobody else can have overall score less than 6 (but it's possible for one other person to have overall score 6 as well), so his overall rank must be 1.

在第一个样例中,克里奥法什的总分为 6。其他任何人都不可能获得低于 6 的总分(但可能有另一人也恰好获得总分 6),因此他的总排名必定为 1。

输入解题思路,AI测评打分。不知道怎么写?

首页