AtCoder Beginner Contest 438
G
Sum of Min
AtCoder
⌀ 2455
原题
← F→
翻译中…

Problem Statement

翻译中…

You are given integers $N,M,K$, a length-$N$ integer sequence $A=(A_0,A_1,\ldots,A_{N-1})$, and a length-$M$ integer sequence $B=(B_0,B_1,\ldots,B_{M-1})$. Note that the indices start from $0$.

翻译中…

Find $\displaystyle\sum_{i=0}^{K-1} \min(A_{i\bmod N}, B_{i \bmod M})$, modulo $998244353$.

翻译中…

Constraints

翻译中…
  • $1\le N,M\le 2\times 10^5$
  • $1\le K\le 10^{18}$
  • $1\le A_i,B_i\le 10^9$
  • All input values are integers.
翻译中…

Input

翻译中…

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

翻译中…

N M K
A_0 A_1 \ldots A_{N-1}
B_0 B_1 \ldots B_{M-1}

翻译中…

Output

翻译中…

Output $\displaystyle\sum_{i=0}^{K-1} \min(A_{i\bmod N}, B_{i \bmod M})$, modulo $998244353$.

翻译中…

样例

Input #1
3 2 5
3 1 4
1 5
Output #1
7
The desired value is $\min(3,1)+\min(1,5)+\min(4,1)+\min(3,5)+\min(1,1)=7$.
Input #2
4 4 27
6 1 10 42
87 6 21 33
Output #2
317
Input #3
5 7 583272014892537201
763832259 547096173 408327452 685495693 212251318
850800766 845647066 240229336 648345577 691868483 740301913 740485849
Output #3
931208848
Compute modulo $998244353$.
题目信息
题号
abc438_g
时间限制
2 s
内存限制
1024 MB

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