All Tracks Algorithms Sorting Problem

Sum of Digits
Tag(s):

Ad-Hoc, Easy, approved

Problem
Editorial
Analytics

You are given an array of $$N$$ distinct numbers. Now, we call the Digit Value of a number to be the sum of its digits..

Now, a subset is a set of not-necessarily-contiguous array elements. We call the value of a set to be the the maximum over the Digit Value of all elements it contains.

Now, you need to find the summation of the values of all $$2^{N}-1$$ non-empty subsets of this array. As the answer can be rather large, print it Modulo $$ 10^9+7 $$. Can you do it ?

Input Format :

The first line contains a single integer $$N$$. The next line contains $$N$$ space separated integers, where the $$i^{th}$$ integer denotes $$A[i]$$.

Output Format :

Print the summation of the value of each non-empty subset of the given array Modulo $$10^9+7$$.

Constraints :

$$ 1 \le N \le 10^{5} $$

$$ 0 \le A[i] \le 10^{18} $$

SAMPLE INPUT
3
10 20 30
SAMPLE OUTPUT
17
Explanation

The subsets of this array and their values are :

  1. (10) : 1

  2. (20) : 2

  3. (30) : 3

  4. (10,20) : 2

  5. (10, 30) : 3

  6. (20,30) : 3

  7. (10,20,30 ) : 3

Thus, the final answer is $$ (1+2+3+2+3+3+3 ) $$ = $$17$$

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

Accolite

Challenge Name

Accolite Java Developer Hiring Challenge

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications