#abc224f. F - Problem where +s Separate Digits

F - Problem where +s Separate Digits

Score : 500500 points

问题描述

给定一个由 1199 的数字组成的字符串 SS

从该字符串 SS 中,我们按照以下操作构建一个公式 TT

  • 首先,令 T=ST=S
  • 选择一个(可能为空)的整数集合 AA,其中每个元素都在 11S1|S|-1(包括两端点)之间,并且所有元素互不相同。
  • 按降序遍历集合 AA 中的每个元素 xx,执行以下操作:
    • TT 的第 xx 个字符和第 (x+1)(x+1) 个字符之间插入一个 + 符号。

例如,当 S=S= 1234 并且 A={2,3}A= \lbrace 2,3 \rbrace 时,我们将得到 TT= 12+3+4

考虑通过这些操作得出的所有可能的公式 TT 的计算结果。求这些计算结果之和对 998244353998244353 取模后的值。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given is a string SS consisting of digits from 11 through 99.
From this string SS, let us make a formula TT by the following operations.

  • Initially, let T=ST=S.
  • Choose a (possibly empty) set AA of different integers where each element is between 11 and S1|S|-1 (inclusive).
  • For each element xx in descending order, do the following.
    • Insert a + between the xx-th and (x+1)(x+1)-th characters of TT.

For example, when S=S= 1234 and A={2,3}A= \lbrace 2,3 \rbrace, we will have TT= 12+3+4.

Consider evaluating all possible formulae TT obtained by these operations. Find the sum, modulo 998244353998244353, of the evaluations.

Constraints

  • 1S2×1051 \le |S| \le 2 \times 10^5
  • SS consists of 1, 2, 3, 4, 5, 6, 7, 8, and 9.

Input

Input is given from Standard Input in the following format:

SS

Output

Print the answer.

Sample Input 1

1234

Sample Output 1

1736

There are eight formulae that can be obtained as TT: 1234, 123+4, 12+34, 12+3+4, 1+234, 1+23+4, 1+2+34, and 1+2+3+4.
The sum of the evaluations of these formulae is 17361736.

Sample Input 2

1

Sample Output 2

1

SS may have a length of 11, in which case the only possible choice for AA is the empty set.

Sample Input 3

31415926535897932384626433832795

Sample Output 3

85607943

Be sure to find the sum modulo 998244353998244353.

update @ 2024/3/10 09:52:00