No.2729 Addition and Multiplication in yukicoder (Easy)
タグ : / 解いたユーザー数 182
作問者 : 👑
kusirakusira
FplusFplusF
みどりむし🦠
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
This problem has a setting similar to Problem G "Addition and Multiplication in yukicoder (Hard)". The differences in the problem statement are shown in red.
Problem Statement
There are $N$ integers $A_1, A_2, \dots, A_N$. There is also a variable $x$, which is initially $x = 0$.
You perform the following operation $1$ time.
- First, choose one permutation $(P_1, P_2, \dots, P_N)$ of $(1, 2, \dots, N)$.
- Next, for $i = 1, 2, \dots, N$ in this order, replace $x$ with $10x + A_{P_i}$.
Find the minimum possible final value of $x$, modulo $998244353$. Note that you are not asked to find the minimum of the value of $x$ modulo $998244353$.
Constraints
- All inputs are integers.
- $1 \leq N \leq 2 \times 10^5$
- $1 \leq A_i \leq 10^{18}$
Input
The input is given from Standard Input in the following format.
$N$ $A_1$ $A_2$ $\dots$ $A_N$
Output
Print the minimum possible final value of $x$, modulo $998244353$.
Sample
Sample 1
Input
3 23 456 1
Output
786
You can choose $(P_1, P_2, P_3) = (3, 1, 2)$. In this case, the value of $x$ changes during the operation as follows.
- Initially, $x = 0$. Since $P_1 = 3$, we have $A_{P_1} = A_3 = 1$. Thus, replace $x$ with $10 \times 0 + 1 = 1$.
- Since $P_2 = 1$, we have $A_{P_2} = A_1 = 23$. Thus, replace $x$ with $10 \times 1 + 23 = 33$.
- Since $P_3 = 2$, we have $A_{P_3} = A_2 = 456$. Thus, replace $x$ with $10 \times 33 + 456 = 786$.
Therefore, the final value of $x$ is $786$, and this is the minimum achievable value.
Sample 2
Input
9 1 22 333 4444 55555 666666 7777777 88888888 999999999
Output
993305167
Print the value modulo $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。