CF1776K.Uniform Chemistry

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In a parallel universe there are nn chemical elements, numbered from 11 to nn. The element number nn has not been discovered so far, and its discovery would be a pinnacle of research and would bring the person who does it eternal fame and the so-called SWERC prize.

There are mm independent researchers, numbered from 11 to mm, that are trying to discover it. Currently, the ii-th researcher has a sample of the element sis_i. Every year, each researcher independently does one fusion experiment. In a fusion experiment, if the researcher currently has a sample of element aa, they produce a sample of an element bb that is chosen uniformly at random between a+1a+1 and nn, and they lose the sample of element aa. The elements discovered by different researchers or in different years are completely independent.

The first researcher to discover element nn will get the SWERC prize. If several researchers discover the element in the same year, they all get the prize. For each i=1, 2, …, mi = 1, \, 2, \, \dots, \, m, you need to compute the probability that the ii-th researcher wins the prize.

在一个平行宇宙中,存在 nn 种化学元素,编号从 11 到 nn。其中,编号为 nn 的元素尚未被发现;它的发现将标志着科研的巅峰成就,并使发现者获得永恒的声誉以及所谓的 SWERC 奖。

共有 mm 位彼此独立的研究员,编号从 11 到 mm,他们正致力于发现该元素。目前,第 ii 位研究员手中拥有一种元素 sis_i 的样品。每年,每位研究员各自独立地进行一次聚变实验:若某研究员当前持有元素 aa 的样品,则他在实验中会以等概率在区间 [a+1,n][a+1, n] 中随机选择一个整数 bb,并由此生成元素 bb 的样品,同时失去元素 aa 的样品。不同研究员之间、或不同年份中所发现的元素完全相互独立。

首位发现元素 nn 的研究员将独享 SWERC 奖;若多位研究员于同一年发现该元素,则他们共同获奖。对每个 i=1, 2, …, mi = 1,\,2,\,\dots,\,m,你需要计算第 ii 位研究员赢得该奖的概率。

输入格式

The first line contains two integers nn and mm (2≤n≤10182 \le n \le 10^{18}, 1≤m≤1001 \le m \le 100) — the number of elements and the number of researchers.

The second line contains mm integers s1, s2, …, sms_1, \, s_2, \, \dots, \, s_m (1≤si<n1 \le s_i \lt n) — the elements that the researchers currently have.

第一行包含两个整数 nn 和 mm(2≤n≤10182 \le n \le 10^{18},1≤m≤1001 \le m \le 100)—— 分别表示元素总数和研究人员数量。

第二行包含 mm 个整数 s1, s2, …, sms_1, \, s_2, \, \dots, \, s_m(1≤si<n1 \le s_i \lt n)—— 表示研究人员当前拥有的元素。

输出格式

Print mm floating-point numbers. The ii-th number should be the probability that the ii-th researcher wins the SWERC prize. Your answer is accepted if each number differs from the correct number by at most 10−810^{-8}.

输出 mm 个浮点数。其中第 ii 个数应为第 ii 位研究人员赢得 SWERC 奖项的概率。若每个数与正确答案的差值均不超过 10−810^{-8},则你的答案将被接受。

输入输出样例

  • 输入#1

    2 3
    1 1 1

    输出#1

    1.0 1.0 1.0
  • 输入#2

    3 3
    1 1 2

    输出#2

    0.5 0.5 1.0
  • 输入#3

    3 3
    1 1 1

    输出#3

    0.625 0.625 0.625
  • 输入#4

    100 7
    1 2 4 8 16 32 64

    输出#4

    0.178593469 0.179810455 0.182306771
    0.187565366 0.199300430 0.229356322
    0.348722518

说明/提示

In the first sample, all researchers will discover element 22 in the first year and win the SWERC prize.

In the second sample, the last researcher will definitely discover element 33 in the first year and win the SWERC prize. The first two researchers have a 50%50\% chance of discovering element 22 and a 50%50\% chance of discovering element 33, and only element 33 will bring them the prize.

In the third sample, each researcher has an independent 50%50\% chance of discovering element 33 in the first year, in which case they definitely win the SWERC prize. Additionally, if they all discover element 22 in the first year, which is a 12.5%12.5\% chance, then they will all discover element 33 in the second year and all win the prize.

在第一个样例中,所有研究人员都将在第一年发现元素 22,并赢得 SWERC 奖项。

在第二个样例中,最后一名研究人员必定在第一年发现元素 33,并赢得 SWERC 奖项。前两名研究人员各有 50%50\% 的概率发现元素 22、50%50\% 的概率发现元素 33,而只有发现元素 33 才能让他们获奖。

在第三个样例中,每名研究人员在第一年独立地以 50%50\% 的概率发现元素 33,此时他们必定赢得 SWERC 奖项。此外,若他们全部在第一年发现元素 22(该事件发生的概率为 12.5%12.5\%),则他们将在第二年全部发现元素 33,并全部获奖。

输入解题思路,AI测评打分。不知道怎么写?

首页