問題一覧 > 通常問題

No.1299 Random Array Score

レベル : / AI推定難易度 : 700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 322
作問者 : nok0 / テスター : zkou Kite_kuma
お気に入りにしたユーザー ProblemId : 5473 / 自分の提出
問題文最終更新日: 2020-11-26 15:02:21
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 276 (順位表) の他の問題:

Problem Statement

You are given a sequence $A$ of $N$ elements. The $i$-th element of the sequence $A$ is $A_i$.

Perform the following operation exactly $K$ times.

  • Choose $1$ element of the sequence $A$ uniformly at random. Add the value of the chosen element to every element of the sequence $A$.
  • Find the expected value of the sum of the elements of the sequence $A$ after the $K$ operations, and output it modulo $\bmod998244353$.

    More precisely, it can be proved under the constraints of this problem that the expected value is a rational number, that is, it can be expressed as an irreducible fraction $\frac{P}{Q}$, and that an integer $R$ satisfying $R×Q≡P(\bmod 998244353),\ 0 \le R< 998244353$ is uniquely determined. Output this $R$.

    Constraints

    • All inputs are integers.
    • $1 \le N\le 2 × 10^5$
    • $0 \le K \le 10^{18}$
    • $0 \le A_i \le 10^9$

    Input

    $N\ K$
    $A_1\  A_2\ \dots \  A_N$
    

    Output

    Output the expected value of the sum of the elements of the sequence $A$ after the $K$ operations, modulo $\bmod 998244353$.

    Sample

    Sample 1
    Input
    3 1
    1 2 3
    Output
    12

    If $A_1$ is chosen in the operation, the sequence $A$ becomes $(1+1,2+1,3+1) = (2,3,4)$.

    Similarly, if $A_2$ is chosen, the sequence $A$ becomes $(1+2,2+2,3+2) = (3,4,5)$.

    Similarly, if $A_3$ is chosen, the sequence $A$ becomes $(1+3,2+3,3+3) = (4,5,6)$.

    Therefore, the expected value of the sum of the sequence $A$ after $1$ operation is $\frac{(2 + 3 +4) + (3 + 4+5)+(4+5+6)}{3} = 12$.

    Sample 2
    Input
    1 0
    1
    Output
    1

    It is possible that no operations are performed.

    Sample 3
    Input
    10 1000000000000000000
    3 1 4 1 5 9 2 6 5 3
    Output
    461591775

    Output the value modulo $\bmod 998244353$.

    提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。