QOJ.ac

QOJ

Limite de temps : 5.0 s Limite de mémoire : 2048 MB Points totaux : 100

#17322. 抽卡

Statistiques

你正在进行一个单人纸牌游戏。牌堆共有 $N$ 张牌,每张牌上写有一个 $0$ 到 $K$ 之间的整数。你将牌堆洗牌并抽取一张牌作为你的初始手牌。随后,你通过反复选择并弃置一张手牌来进行游戏。每当你弃置一张牌时,你从牌堆顶部抽取与该牌上数字等量的牌加入手牌(如果牌堆中剩余的牌不足,则将剩余的牌全部抽取)。如果你抽完了牌堆中所有的牌,则你获胜;如果你的手牌用尽但牌堆中仍有剩余的牌,则你失败。给定牌堆的内容,假设所有可能的洗牌方式等概率出现,且你采取最优策略,请问你获胜的概率是多少?

输入格式

第一行包含两个空格分隔的整数 $N$ 和 $K$,其中 $N$ ($1 \le N \le 1500$) 是牌堆中的牌数,$K$ ($0 \le K \le 3$) 是牌上写有的最大整数。

第二行包含 $K+1$ 个空格分隔的整数 $a_i$ ($0 \le a_i \le N$),从 $i=0$ 开始:表示牌堆中写有数字 $i$ 的牌的数量。保证 $a_K > 0$ 且所有 $a_i$ 之和为 $N$。

输出格式

输出一个实数:表示在最优策略下你获胜的概率。如果你的答案与标准答案的绝对误差不超过 $10^{-6}$,则会被接受。

样例

样例输入 1

4 2
2 0 2

样例输出 1

0.3333333333333333

样例输入 2

5 1
3 2

样例输出 2

0.0

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.