A8205 | Basketball Team
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
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.
输出格式
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}$ .
输入输出样例
输入 #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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted