I have an even number 1 to 10 and each number have a frequency that comes up.
example the number 2,4,6,8 then the frequency of each number are 2,1,0,0.It means that we can use up to two digits of 2 and one digit of 4. There are exactly 8 distinct numbers that can be
constructed using the above digits: 2, 4, 22, 24, 42, 224, 242, 422. The sum of all those numbers is 982. but the first line of input contains an integer T (T ≤ 500) denoting the number of testcases. Each testcase contains nine (not four) integers Pi (0 ≤ Pi ≤ 9) denoting the number of i-th digit for i = 1..9.
And the Output For each
test case, the output contains a line in the format Case #x: M, where x is the case number (starting from 1) and M is the output in a single line the sum of all possible numbers generated from the available digits. Modulo the output with 1,000,000,007.
I have tried to sum up 1 to 1000. How I settle to the case above?
Code: