Lets not waste your time with long tiring problem statement and just go straight to the point. You are given an array containing numbers. You are also given a function. You need to find the result of the function using array for a specific .
function solveMeIfYouCan(A,K)
result = 0
subsetList = all the non empty subsets of array A
for all subset s in subsetList
sortedSubset = sort the elements inside subset from small to large
size = element count in sortedSubset
len = min(size, K)
for i = 1 to len
result = result + sortedSubset[i]
end for
end for
return result
end function
Note: Array indexing starts from 1.
Since finding the answer for a single will be too easy, you need to find the answer for all possible (1 to ).
The first line contains an integer, (), number of tests. The second line contains an integer, (), number of elements in . Next line contains characters denoting the elements of the array ().
For each test case print a line contains exactly numbers denoting the answer for all possible (1 to ). The answer may be very large, so you need to print the answer modulo 786433.
Input | Output |
---|---|
3 3 1 1 1 3 1 2 3 4 1 2 3 4 | 7 11 12 11 21 24 26 58 76 80 |