#abc224f. F - Problem where +s Separate Digits
F - Problem where +s Separate Digits
Score : points
问题描述
给定一个由 到 的数字组成的字符串 。
从该字符串 中,我们按照以下操作构建一个公式 :
- 首先,令 。
- 选择一个(可能为空)的整数集合 ,其中每个元素都在 和 (包括两端点)之间,并且所有元素互不相同。
- 按降序遍历集合 中的每个元素 ,执行以下操作:
- 在 的第 个字符和第 个字符之间插入一个
+
符号。
- 在 的第 个字符和第 个字符之间插入一个
例如,当 1234
并且 时,我们将得到 = 12+3+4
。
考虑通过这些操作得出的所有可能的公式 的计算结果。求这些计算结果之和对 取模后的值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given is a string consisting of digits from through .
From this string , let us make a formula by the following operations.
- Initially, let .
- Choose a (possibly empty) set of different integers where each element is between and (inclusive).
- For each element in descending order, do the following.
- Insert a
+
between the -th and -th characters of .
- Insert a
For example, when 1234
and , we will have = 12+3+4
.
Consider evaluating all possible formulae obtained by these operations. Find the sum, modulo , of the evaluations.
Constraints
- consists of
1
,2
,3
,4
,5
,6
,7
,8
, and9
.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
1234
Sample Output 1
1736
There are eight formulae that can be obtained as : 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 .
Sample Input 2
1
Sample Output 2
1
may have a length of , in which case the only possible choice for is the empty set.
Sample Input 3
31415926535897932384626433832795
Sample Output 3
85607943
Be sure to find the sum modulo .
update @ 2024/3/10 09:52:00