当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6243:Dogs and Cages

Special Judge 特殊评判
题目描述
Jerry likes dogs. He has $N$ dogs numbered $0, 1, ..., N-1$. He also has $N$ cages numbered $0, 1, ..., N-1$. Everyday he takes all his dogs out and walks them outside. When he is back home, as dogs can’t recognize the numbers, each dog just randomly selects a cage and enters it. Each cage can hold only one dog.
One day, Jerry noticed that some dogs were in the cage with the same number of themselves while others were not. Jerry would like to know what’s the expected number of dogs that are NOT in the cage with the same number of themselves.
输入解释
The first line of the input gives the number of test cases, $T$. $T$ test cases follow.
Each test case contains only one number $N$, indicating the number of dogs and cages.
$1 \leq T \leq 10^5$
$1 \leq N \leq 10^5$
输出解释
For each test case, output one line containing “Case #x: y”, where $x$ is the test case number (starting from 1) and $y$ is the expected number of dogs that are NOT in the cage with the same number of itself.
$y$ will be considered correct if it is within an absolute or relative error of $10^{-6}$ of the correct answer.
输入样例
2
1
2
输出样例
Case #1: 0.0000000000
Case #2: 1.0000000000
提示
In the first test case, the only dog will enter the only cage. So the answer is 0.
In the second test case, if the first dog enters the cage of the same number, both dogs are in the cage of the same number, 
the number of mismatch is 0. If both dogs are not in the cage with the same number of itself, the number of mismatch is 2. 
So the expected number is (0+2)/2=1.
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6243

最后修改于 2020-10-25T23:29:37+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)