201540: [AtCoder]ARC154 A - Swap Digit

Memory Limit:1024 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $300$ points

Problem Statement

You are given $N$-digit positive integers $A$ and $B$ whose topmost digits are not $0$.

You can repeat the following operation any number of times (possibly zero).

  • Choose an integer $i$ such that $1 \le i \le N$ and swap the $i$-th lowest digits of $A$ and $B$.

Find the smallest possible value of $A \times B$ after your operations, modulo $998244353$.

Note that you are not asked to minimize the remainder when $A \times B$ is divided by $998244353$.

Constraints

  • $1 \le N \le 200000$
  • $A$ and $B$ are $N$-digit positive integers whose topmost digits are not $0$.

Input

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

$N$
$A$
$B$

Output

Print a single line containing the answer.


Sample Input 1

2
13
22

Sample Output 1

276

You can make $A \times B = 276$ by performing the operation once, as follows.

  • Choose $i=1$ to swap the bottommost digits of $A$ and $B$, making $A=12, B=23$.

You cannot make $A \times B = 275$ or less, so the answer is $276$.


Sample Input 2

8
20220122
21002300

Sample Output 2

54558365

Find the value modulo $998244353$.

Input

题意翻译

有两个 $n$ 位数,可以交换任意次对应位上的数(可以是 $0$ 次),希望最小化交换后两个数的乘积,输出对 $998244353$ 取模的结果。

加入题单

上一题 下一题 算法标签: