QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 1024 MB Points totaux : 100

#11321. 狗与笼子

Statistiques

Jerry 喜欢狗。他有 $N$ 只狗,编号为 $0, 1, \dots, N-1$。他还有 $N$ 个笼子,编号为 $0, 1, \dots, N-1$。每天他带所有的狗出去散步。当他回到家时,由于狗无法识别数字,每只狗都会随机选择一个笼子并进入。每个笼子只能容纳一只狗。

有一天,Jerry 注意到有些狗进入了与它们编号相同的笼子,而另一些则没有。Jerry 想知道,不在编号相同笼子里的狗的期望数量是多少。

输入格式

输入的第一行包含测试用例的数量 $T$。接下来有 $T$ 个测试用例。 每个测试用例仅包含一个数字 $N$,表示狗和笼子的数量。

输出格式

对于每个测试用例,输出一行 "Case #x: y",其中 $x$ 是测试用例编号(从 1 开始),$y$ 是不在编号相同笼子里的狗的期望数量。如果 $y$ 与正确答案的绝对误差或相对误差在 $10^{-6}$ 以内,则被视为正确。

数据范围

  • $1 \le T \le 10^5$
  • $1 \le N \le 10^5$

样例

输入 1

2
1
2

输出 1

Case #1: 0.0000000000
Case #2: 1.0000000000

说明

在第一个测试用例中,唯一的狗会进入唯一的笼子。所以答案是 0。

在第二个测试用例中,如果第一只狗进入了编号相同的笼子,那么两只狗都在编号相同的笼子里,不匹配的数量为 0。如果两只狗都没有进入编号相同的笼子,那么不匹配的数量为 2。所以期望数量是 $\frac{0+2}{2} = 1$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.