オムロンプログラミングコンテスト2025 #2(AtCoder Beginner Contest 432)
G
Sum of Binom(A, B)
AtCoder
⌀ 1984
原题
← F→
翻译中…

Problem Statement

翻译中…

You are given a sequence of positive integers $A=(A_1,A_2,\dots,A_N)$ of length $N$ and a sequence of positive integers $B=(B_1,B_2,\dots,B_M)$ of length $M$.

翻译中…

Find the value of $\displaystyle \sum_{i=1}^{N} \sum_{j=1}^{M} \binom{A_i}{B_j}$, modulo $998244353$.

翻译中…

Here, $\displaystyle \binom{x}{y}$ represents the number of ways to choose $y$ objects from $x$ objects (binomial coefficient), and particularly, it is $0$ if $x < y$.

翻译中…

Constraints

翻译中…
  • $1\leq N,M \leq 5\times 10^5$
  • $1\leq A_i,B_j \leq 5\times 10^5$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N M
A_1 A_2 \dots A_N
B_1 B_2 \dots B_M

翻译中…

Output

翻译中…

Output the answer.

翻译中…

样例

Input #1
3 2
2 5 4
1 3
Output #1
25
The answer is $\displaystyle \binom{2}{1}+\binom{2}{3}+\binom{5}{1}+\binom{5}{3}+\binom{4}{1}+\binom{4}{3}=2+0+5+10+4+4=25$.
Input #2
4 4
2 5 1 5
2 1 2 4
Output #2
65
Input #3
6 8
203497 47202 407775 394325 463982 304784
468417 302156 131932 235902 395728 78537 223857 330739
Output #3
602855848
题目信息
题号
abc432_g
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。