#B. Products of Min-Max

    Type: Default 1000ms 256MiB

Products of Min-Max

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

[ARC116B] Products of Min-Max

题面翻译

给定一个长为 NN 的序列 AA,在 AA 的所有 2N12^N-1 个非空子序列 BB 中,求所有的 max{B}×min{B}\max\{B\}\times\min\{B\} 的和。模 998244353998244353 输出。

输入格式

第一行一个整数 NN ,第二行 NN 个整数 AiA_i

NN A1A_1 A2A_2 \cdots ANA_N

输出格式

一个整数表示答案。

样例 #1

样例输入 #1

3
2 4 3

样例输出 #1

63

样例 #2

样例输入 #2

1
10

样例输出 #2

100

样例 #3

样例输入 #3

7
853983 14095 543053 143209 4324 524361 45154

样例输出 #3

206521341

提示

数据范围

  • 1  N  2 × 1051\ \leq\ N\ \leq\ 2\ \times\ 10^5
  • 0  Ai  9982443520\ \leq\ A_i\ \leq\ 998244352

20241224集训

Not Attended
Status
Done
Rule
IOI
Problem
6
Start at
2024-12-24 19:00
End at
2024-12-24 21:00
Duration
2 hour(s)
Host
Partic.
15