Professor Math is working on a secret project and is facing a challenge where a list of numbers need to be encoded into a single number in the most efficient manner. After much research, Professor Math finds a 3 step process that can best encode the numbers:
The professor has shared an example and its explanation below. Given a list of numbers, can you help the professor build an efficient function to compute the final encoded number?
The first line of the input gives the number of test cases, T. This is followed by T test cases where each test case is defined by 2 lines:
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the final encoded number.
Since the output can be a really big number, we only ask you to output the remainder of dividing the result by the prime 109 + 7 (1000000007).
Find all subsets and get the difference between largest & smallest numbers:
Find the sum of the differences calculated in the previous step: 3+4+6+1+3+2+4+6+6+3+6 = 44.
Find the answer modulo 109 + 7 (1000000007): 44 % 1000000007 = 44