estie プログラミングコンテスト2025 (AtCoder Regular Contest 210)
F
± ab
AtCoder
未评级
原题
← E→
翻译中…

Problem Statement

翻译中…

You are given an integer sequence $A=(A_1,A_2,\ldots,A_N)$. Also, you are given positive integers $a,b,s,t$. It is guaranteed that $a$ and $b$ are coprime.

翻译中…

You can perform the following four types of operations on $A$:

翻译中…
  • Choose an integer $i$ satisfying $1\leq i\leq N$ and add $a$ to $A_i$. This operation costs $s$.
  • Choose an integer $i$ satisfying $1\leq i\leq N$ and subtract $a$ from $A_i$. This operation costs $s$.
  • Choose an integer $i$ satisfying $1\leq i\leq N$ and add $b$ to $A_i$. This operation costs $t$.
  • Choose an integer $i$ satisfying $1\leq i\leq N$ and subtract $b$ from $A_i$. This operation costs $t$.
翻译中…

Answer $Q$ queries. In the $q$-th query, you are given an integer $B_q$, so find the following value modulo $998244353$:

翻译中…
  • The minimum total cost required to make $A_{1}=A_{2}=\cdots=A_{N}=B_q$ hold. It can be proved that it is possible to make $A_{1}=A_{2}=\cdots=A_{N}=B_q$ hold.
翻译中…

Constraints

翻译中…
  • $1\leq N\leq 2\times 10^5$
  • $1\leq Q\leq 2\times 10^5$
  • $1\leq a,b,s,t\leq 5\times 10^8$
  • $a$ and $b$ are coprime.
  • $1\leq A_i\leq 5\times 10^8$
  • $1\leq B_q\leq 5\times 10^8$
翻译中…

Input

翻译中…

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

翻译中…

N Q
a b s t
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_Q

翻译中…

Output

翻译中…

Output $Q$ values separated by spaces.

翻译中…

The $q$-th value should be the minimum total cost, modulo $998244353$, required to make $A_{1}=A_{2}=\cdots=A_{N}=B_q$ hold.

翻译中…

样例

Input #1
1 5
3 5 4 3
3
1 2 3 4 5
Output #1
7 11 0 11 7
- By performing operations $+a$, $-b$ on $A_1$ in order, we can make $A=(1)$. The total cost is $4+3=7$. - By performing operations $-a$, $-a$, $+b$ on $A_1$ in order, we can make $A=(2)$. The total cost is $4+4+3=11$. - $A=(3)$ from the beginning. The total cost is $0$. - By performing operations $+a$, $+a$, $-b$ on $A_1$ in order, we can make $A=(4)$. The total cost is $4+4+3=11$. - By performing operations $-a$, $+b$ on $A_1$ in order, we can make $A=(5)$. The total cost is $4+3=7$.
Input #2
3 1
3 5 4 3
1 2 3
4
Output #2
22
- By performing operations $+a$ on $A_1$, $+b$, $-a$ on $A_2$, and $+a,+a,-b$ on $A_3$ in order, we can make $A=(4,4,4)$. The total cost is $22$.
Input #3
5 5
1234 4321 5 5
1 10 100 1000 10000
123 4567 89012345 6 789
Output #3
45340 42530 531725 35135 41690
题目信息
题号
arc210_f
时间限制
10 s
内存限制
1024 MB

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