Chopsticks

시간 제한2초메모리 제한2048 MB

요약
여러 종류의 젓가락에서 2n개를 무작위로 뽑을 때 짝이 맞지 않는 손님 수의 기댓값에 C(s, 2n)을 곱한 값을 998244353으로 나눈 나머지를 구한다.
난이도

어려움10점 중 8점

유형
조합론, 동적 계획법, 수학, 누적 합
정답자
아직 제출이 없습니다

문제

Chisato works at a traditional Japanese restaurant that just received a shipment of beautifully handcrafted chopsticks. There are mm different types of chopsticks, and for each type ii (1≤i≤m1 ≤ i ≤ m), there are exactly k_ik\_i chopsticks.

Tonight, nn guests have arrived, and each guest needs exactly one pair of chopsticks. Since no type of chopstick has at least 2n2n pieces, Chisato decides to randomly select 2n2n chopsticks from the full collection, which contains s=∑_i=1mk_is = \sum\_{i=1}^{m}{k\_i} chopsticks in total.

After selecting the 2n2n chopsticks, Chisato will try to distribute them in a way that maximizes the number of guests receiving a matching pair, that is, two chopsticks of the same type. If it’s not possible to provide matching pairs for everyone, some guests will receive mismatched pairs.

Your task is to compute the expected number of guests who receive mismatched pairs of chopsticks under this strategy.

입력

The first line contains two integers nn and mm, representing the number of people and the number of the chopstick type, respectively.

The second line contains mm integers, the ii-th integer k_ik\_i represents the number of chopstick for the ii-th type.

출력

Print a single integer, the expected number of people who cannot get a pair of chopsticks of the same type, multiplied by (s2n)\displaystyle\binom{s}{2n} (where s=∑_i=1mk_is = \sum\_{i=1}^{m}{k\_i}). It can be proven that this product is an integer. Output the result modulo 998244353998244353.

제한

  • 1≤n≤2.5×1051 ≤ n ≤ 2.5 \times 10^5
  • 1≤m≤5×1051 ≤ m ≤ 5 \times 10^5
  • 1≤k_i<2×n1 ≤ k\_i < 2 \times n
  • 2×n≤s2 \times n ≤ s

예제3

  1. 예제 1

    입력
    3 3
    2 2 2
    
    예상 출력
    0
    
  2. 예제 2

    입력
    5 3
    3 3 4
    
    예상 출력
    1
    
  3. 예제 3

    입력
    5 2
    8 8
    
    예상 출력
    4032