time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 si — 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.

Input

The first line contains three integers nm 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 si (1 ≤ si ≤ 100), denoting the number of students in the i-th department. Note that sh includes Herr Wafa.

Output

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.

Sample test(s)
input
3 2 1 2 1
output
1.0
input
3 2 1 1 1
output
-1.0
input
3 2 1 2 2
output
0.6666666666666667
Note

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.

 /*
输入:n,m,k,
a[i];
正难则反!总方案数为1-C(s-a[k],n-1)/C(s-1,n-1)
*/ #include <stdio.h>
const long long mo = ;
typedef long long ll; int a[];
int main()
{
int m, n, k, i, j;
while (~scanf("%d%d%d", &n, &m, &k))
{
int s = ;
for (i = ; i <= m; i++)
{
scanf("%d", &a[i]);
s += a[i];
}
if (s < n)
{
printf("-1.0\n");
continue;
}
double ans, tmp = 1.0;
int s1, s2;
s1 = s - ;
s2 = s - a[k];
for (i = ; i <= n - ; i++)
{
tmp = tmp * s2 / s1;
s2--;
s1--;
}
ans = 1.0 - tmp;
printf("%.15f\n", ans);
} return ;
}

codeforces 108D Basketball Team(简单组合)的更多相关文章

  1. Codeforces 107B Basketball Team 简单概率

    题目链接:点击打开链接 题意: 给定n m h 表示有m个部门,有个人如今在部门h 以下m个数字表示每一个部门的人数.(包含他自己) 在这些人中随机挑选n个人,问挑出的人中存在和这个人同部门的概率是多 ...

  2. find xargs 简单组合使用

    简单总结下,留作自己以后拾遗...... 一.find xargs 简单组合 ## mv 小结find ./ -type f -name "*.sh"|xargs mv -t /o ...

  3. XKC's basketball team【线段树查询】

    XKC , the captain of the basketball team , is directing a train of nn team members. He makes all mem ...

  4. [单调队列]XKC's basketball team

    XKC's basketball team 题意:给定一个序列,从每一个数后面比它大至少 \(m\) 的数中求出与它之间最大的距离.如果没有则为 \(-1\). 题解:从后向前维护一个递增的队列,从后 ...

  5. The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 XKC's basketball team

    XKC , the captain of the basketball team , is directing a train of nn team members. He makes all mem ...

  6. codeforces 57 C Array(简单排列组合)

    C. Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  7. CodeForces - 401C Team(简单构造)

    题意:要求构造一个字符串,要求不能有连续的两个0在一起,也不能有连续的三个1在一起. 分析: 1.假设有4个0,最多能构造的长度为11011011011011,即10个1,因此若m > (n + ...

  8. Codeforces 1108D - Diverse Garland - [简单DP]

    题目链接:http://codeforces.com/problemset/problem/1108/D time limit per test 1 secondmemory limit per te ...

  9. Codeforces - 702A - Maximum Increase - 简单dp

    DP的学习计划,刷 https://codeforces.com/problemset?order=BY_RATING_ASC&tags=dp 遇到了这道题 https://codeforce ...

随机推荐

  1. LINK : fatal error LNK1104: 无法打开文件“qtmaind.lib”

    LINK : fatal error LNK1104: 无法打开文件"qtmaind.lib" VS2019+QT5.13出现该问题,可以尝试这样解决. 1.找打qtmaind.l ...

  2. SSH port forwarding: bind: Cannot assign requested address

    https://www.electricmonk.nl/log/2014/09/24/ssh-port-forwarding-bind-cannot-assign-requested-address/

  3. 阶段3 1.Mybatis_04.自定义Mybatis框架基于注解开发_2 回顾自定义mybatis的流程分析

  4. CentOS6.5 编译安装PHP5.6(apache模块)

    一.环境准备 1. 下载php源码包 # wget http://cn2.php.net/distributions/php-5.6.30.tar.gz # tar -xf php-5.6.30.ta ...

  5. Scratch少儿编程系列:(七)太阳系八大行星的运转

    一.程序说明 本程序用来模拟太阳系八大行星的运转过程. 二.程序流程图 为了更直观的描述上述过程,采用流程图的方式将猜数字的过程进行描述. 还在制作中... 三.制作过程 1. 场景和角色的选择 场景 ...

  6. MSSQL注入--反弹注入

    明明是sql注入的点,却无法进行注入,注射工具拆解的速度异常的缓慢,错误提示信息关闭,无法返回注入的结果,这个时候你便可以尝试使用反弹注入, 反弹注入需要依赖于函数opendatasource的支持, ...

  7. Golang中log与fmt区别

    关于使用log与使用fmt的区别 最初的就是直接打印出来,之后一点点升级,比如加上输出的时间,加上goroutine之间的并发操作(打印信息并不能一定按照你规定好的顺序输出来 每次输出的顺序可能会不同 ...

  8. Java中的静态变量、静态方法、静态代码块

    转载自http://www.cnblogs.com/panjun-Donet/archive/2010/08/10/1796209.html (一)静态方法(1)在Java里,可以定义一个不需要创建对 ...

  9. 【转】MySQL查询缓存详解

    [转]MySQL查询缓存详解 转自:https://www.cnblogs.com/Alight/p/3981999.html 相关文章:http://www.zsythink.net/archive ...

  10. CentOS7 内核模块管理

    1.查看所有模块:lsmod 2.查看指定模块的详细信息:modinfo 模块名 3.动态加载模块:modprobe 模块名 4.动态卸载模块:modprobe -r 模块名 5.开机自动加载模块:假 ...