Sum Of All
Practice
4.8 (4 votes)
Math
Algorithms
Modulus arithmetic
Number theory
Problem
89% Success 678 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a number. You want to compute the sum of all possible resulting numbers after applying the magic operation.
In a magic operation, you pick a non-empty subsequence from this number, then take these digits out of the number. The remaining digits then fill in the gap, and the number after the magic operation is the integer that is left.

For eg: Let's say the number is \(12345\). One of the subsequences of this number is \(24\)So after removing this subsequence, the resulting number is \(135\).
Leading zeros are allowed in the resulting number (number after applying the magic operation). When all digits are removed, the number is considered to be \(0\).

Input Format:

  • The first line contains one integer \(T\) \(-\) the number of test cases. Then \(T\) test cases follow.
  • The first and only line of each test case contains a single integer \(N\).

Output Format:

For each test case output in a seperate line\(:\)
The sum of all possible resulting numbers after applying the magic operation modulo \((10^9 + 7)\).

Constraints:

  • \(1 \leq T \leq 10^5\)
  • \(1 \leq N \leq 10^{100000}\)
  • It is guaranteed that sum of \(N\) over all test cases doesn't exceed \(10^{100000}\)

 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
MathematicsMediumModular arithmeticNumber Theory
Points:30
6 votes
Tags:
ArraysNumber TheoryData Structures1-DMathModulus Arithmetic
Points:30
Tags:
MediumModular arithmeticNumber Theory