CF107B.Basketball Team

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC).

A team is to be formed of n players, all of which are GUC students. However, the team might have players belonging to different departments. There are m departments in GUC, numbered from 1 to m. Herr Wafa's department has number h. For each department i, Herr Wafa knows number s__i — how many students who play basketball belong to this department.

Herr Wafa was also able to guarantee a spot on the team, using his special powers. But since he hates floating-point numbers, he needs your help at finding the probability that he will have at least one teammate belonging to his department.

Note that every possible team containing Herr Wafa is equally probable. Consider all the students different from each other.

作为一名德国开罗大学(GUC)的学生兼篮球运动员,Herr Wafa 在听到这一消息时欣喜若狂:GUC 终于要参加一年一度的篮球锦标赛(ABC)了!

需组建一支由 n 名球员组成的队伍,所有球员均为 GUC 的学生。然而,这支队伍中的球员可能来自不同的院系。GUC 共有 m 个院系,编号从 1 到 m。Herr Wafa 所在的院系编号为 h。对于每个院系 i,Herr Wafa 已知数值 s__i —— 即该院系中打篮球的学生人数。

此外,Herr Wafa 凭借其特殊能力已确保自己稳获一个参赛名额。但由于他厌恶浮点数,他需要你帮忙计算:在他所在的队伍中,至少还有一名队友与他同属一个院系的概率。

注意:所有包含 Herr Wafa 的可能队伍出现的可能性均等。假设所有学生彼此互不相同。

输入格式

The first line contains three integers n, m and h (1 ≤ n ≤ 100, 1 ≤ m ≤ 1000, 1 ≤ h ≤ m) — the number of players on the team, the number of departments in GUC and Herr Wafa's department, correspondingly.

The second line contains a single-space-separated list of m integers s__i (1 ≤ s__i ≤ 100), denoting the number of students in the i-th department. Note that s__h includes Herr Wafa.

第一行包含三个整数 nn、mm 和 hh(1 ≤ n ≤ 1001 ≤ n ≤ 100,1 ≤ m ≤ 10001 ≤ m ≤ 1000,1 ≤ h ≤ m1 ≤ h ≤ m),分别表示队伍中的球员人数、GUC 中的院系数以及 Herr Wafa 所在的院系编号。

第二行包含一个由空格分隔的、长度为 mm 的整数列表 sis_i(1 ≤ si ≤ 1001 ≤ s_i ≤ 100),其中 sis_i 表示第 ii 个院系的学生人数。注意:shs_h 包含 Herr Wafa 在内。

输出格式

Print the probability that Herr Wafa will have at least one teammate from his department. If there is not enough basketball players in GUC to participate in ABC, print -1. The answer will be accepted if it has absolute or relative error not exceeding 10 - 6.

输出 Herr Wafa 至少有一名队友来自其所在院系的概率。如果 GUC 没有足够的篮球运动员参加 ABC,则输出 -1。若答案的绝对误差或相对误差不超过 10−610^{-6},则视为正确。

输入输出样例

  • 输入#1

    3 2 1
    2 1

    输出#1

    1
  • 输入#2

    3 2 1
    1 1

    输出#2

    -1
  • 输入#3

    3 2 1
    2 2

    输出#3

    0.666667

说明/提示

In the first example all 3 players (2 from department 1 and 1 from department 2) must be chosen for the team. Both players from Wafa's departments will be chosen, so he's guaranteed to have a teammate from his department.

In the second example, there are not enough players.

In the third example, there are three possibilities to compose the team containing Herr Wafa. In two of them the other player from Herr Wafa's department is part of the team.

在第一个例子中,必须从所有 3 名选手(部门 1 的 2 名,部门 2 的 1 名)中选出组队。Wafa 所在部门的两名选手均被选中,因此他必定会有一名来自自己部门的队友。

在第二个例子中,选手人数不足。

在第三个例子中,存在三种包含 Herr Wafa 的组队方案。其中两种方案中,Herr Wafa 所在部门的另一名选手也被选入队伍。

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

首页