QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 100

#3381. 生日派对

الإحصائيات

有 $N$ 个人受邀参加一个特殊的生日派对。每个人都带了一份礼物,但每份礼物的接收者是随机决定的。一个人永远不会收到自己的礼物,但其他所有人收到该礼物的概率均等。求派对中存在 $k$ 个人,使得第 1 个人把礼物送给第 2 个人,第 2 个人把礼物送给第 3 个人,以此类推,直到第 $k$ 个人把礼物送给第 1 个人的概率。

输入的第一行包含一个整数 $T$,表示测试用例的数量。每个测试用例包含两个整数 $N$ 和 $k$。

对于每个测试用例,输出概率,要求精度至少达到 $10^{-6}$。

  • $0 < T \le 30$
  • $2 \le N \le 10000000$
  • $2 \le k \le N$

样例

输入格式 1

4
2 2
3 2
3 3
10 3

输出格式 1

1.000000000
0.750000000
0.250000000
0.313469843

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.