問題一覧 > 通常問題

No.1554 array_and_me

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 59
作問者 : theory_and_me / テスター : shotoyoo
お気に入りにしたユーザー ProblemId : 5031 / 自分の提出
問題文最終更新日: 2021-06-18 21:59:31
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 300 (順位表) の他の問題:

Problem Statement

You are given positive integers $N, K$ and a sequence of positive integers $A_1, A_2, \ldots, A_N$ of length $N$.

Initialize all elements of an array $z = [z_1, z_2, \ldots, z_{N}]$ of length $N$ to 0, and then perform the following operation $K$ times.

1. Choose an integer $i \in \{1, 2, \ldots, N \}$ at random. Here, the probability that $i$ is chosen is $\frac{A_i}{\sum_{i=1}^{N}A_i}$, and the trials are independent for each operation.
2. For the chosen $i$, update $z_i \leftarrow z_i + 1$.

Let $S$ be the set of all non-negative integer arrays of length $N$, and for $x \in S$, let $f(x)$ be the probability that $z = x$ after the above operations are finished.
Compute $\max_{x \in S} f(x)$.

It can be proved under the constraints of this problem that $\max_{x \in S} f(x)$ can be expressed as an irreducible fraction $\frac{P}{Q}$, and that an integer $R$ satisfying $R \times Q \equiv P \ (\mathrm{mod}\ 998244353)$ and $0 \leq R < 998244353$ is uniquely determined. Output this $R$.

You are given $T$ test cases; solve each of them.

Input

The first line of the input is as follows.
$T$
Then, $T$ test cases follow, each in the following format.
$N$ $K$
$A_1 A_2 \ldots A_N$

  • All inputs are integers.
  • $1 \leq T \leq 100$
  • $1 \leq N \leq 10^5$
  • $1 \leq K \leq 10^5$
  • $1 \leq A_i \leq 10^3$
  • The sum of $N$ over all test cases is at most $10^5$.
  • The sum of $K$ over all test cases is at most $10^5$.
  • Output

    Output the value of $R$ on each line. Print a newline at the end.

    Sample

    Sample 1
    Input
    3
    2 2
    1 1
    3 1
    2 3 3
    5 10
    31 41 59 26 53
    
    Output
    499122177
    623902721
    484466660
    

  • Explanation of the first test case
  • For $x = [2, 0]$, $f(x) = \frac{1}{4}$; for $x = [1, 1]$, $f(x) = \frac{1}{2}$; for $x = [0, 2]$, $f(x) = \frac{1}{4}$; and for any other $x \in S$, $f(x) = 0$. Therefore, $\max_{x \in S} f(x) = \frac{1}{2}$.

  • Explanation of the second test case
  • For $x = [1, 0, 0]$, $f(x) = \frac{1}{4}$; for $x = [0, 1, 0]$, $f(x) = \frac{3}{8}$; for $x = [0, 0, 1]$, $f(x) = \frac{3}{8}$; and for any other $x \in S$, $f(x) = 0$. Therefore, $\max_{x \in S} f(x) = \frac{3}{8}$.

  • There is no explanation for the third test case.
  • 提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。