John's Math Problem
Time limit1sMemory limit1024 MB
Given an integer N, sum the values of every number formed by deleting zero or more digits (subsequences), counting duplicates once per way, modulo 998244353.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Math, Implementation
- Solved
- No attempts yet
Problem
Farmer John, given his line of work, makes many math problems. This one is a simple math problem. You have to solve it.
You are given an integer . You may remove zero or more digits from and concatenate the remaining digits in order to form a new number. You cannot remove every digit.
For example, if , the new numbers you can form are 1, 2, 11, 12, 21, and 121.
Find the sum of all new numbers you can form.
Input
An integer is given. does not begin with 0.
Output
Print the sum of all new numbers you can form, modulo . If a number can be formed in several ways, add it once for each way, and ignore leading zeros when adding. For example, when , the number 11 must be added 3 times, and the value to print is .