atcoder#ABC224F. [ABC224F] Problem where +s Separate Digits
[ABC224F] Problem where +s Separate Digits
Score : points
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 .
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.
1234
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 .
1
1
may have a length of , in which case the only possible choice for is the empty set.
31415926535897932384626433832795
85607943
Be sure to find the sum modulo .