Logo
(追記) (追記ここまで)

21270번 - Find the LCA 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 1024 MB338621.429%

문제

You are given an integer sequence $A_1,A_2,\ldots,A_N$. You'll make a rooted tree with $N$ vertices numbered from 1ドル$ through $N$. The vertex 1ドル$ is the root, and for each vertex $i$ (2ドル \leq i \leq N$), its parent $p_i$ must satisfy $p_i<i$.

You define the score of a rooted tree as follows:

  • Let $x$ be the lowest common ancestor of the vertex $N-1$ and the vertex $N$. Then, the score is $$ \prod_{v \in (\text{subtree rooted at $x$})} A_v $$ Note that we consider $x$ itself is in the subtree rooted at $x$.

There are $(N-1)!$ ways to make a tree. Find the sum of scores of all possible trees, modulo 998244353ドル$.

입력

The first line contains an integer $N$ (3ドル \leq N \leq 250000$).

The second line contains integers $A_1,A_2,\ldots,A_N$ (1ドル \leq A_i < 998244353$).

출력

Print the answer.

제한

예제 입력 1

3
2 2 2

예제 출력 1

12

예제 입력 2

5
1 2 3 4 5

예제 출력 2

2080

힌트

출처

Contest > Open Cup > 2020/2021 Season > Stage 14: Grand Prix of Tokyo F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /