Back to task list
Let us calculate sum of digits, as earlier, but multiplying each digit by its position (counting from the left, starting
from 1). For example, given the value
1776 we calculate such weighted sum of digits (let us call it "wsd") as:
wsd(1776) = 1 * 1 + 7 * 2 + 7 * 3 + 6 * 4 = 60
You will be given the number of test-cases in the first line and values itself in the second. For each of the values you are to calculate weighted sum of digits. As usually, put results in one line, separating them with spaces. Example:
input data: 3 9 15 1776 answer: 9 11 60
If you are curious, "weighted sum" is one of technics useful for creating checksums and hashes (though addition and multiplication could be substituted by other similar operations from logic or modular arithmetic).