values and a list of queries queries, where queries[i] = [start, step].
The answer to a query is the sum of values[j] over every index j from start to the end of the array such that j - start is divisible by step. In other words, start at start and jump right by step positions until you leave the array.
Return the answers to all queries in order, each taken modulo 10⁹ + 7.
There are many queries and the steps can be small, so walking every query separately may be too slow.values=[4, 0, 7, 1, 9, 2], queries=[[0, 2], [1, 4], [3, 10]] → [20, 2, 1]
Query [0, 2] takes indices 0, 2, 4: 4 + 7 + 9 = 20. Query [1, 4] takes indices 1 and 5: 0 + 2 = 2. Query [3, 10] takes only index 3: 1.
values=[1000000000, 1000000000, 1000000000], queries=[[0, 1]] → [999999986]
The sum is 3,000,000,000, which is 999,999,986 modulo 10⁹ + 7.
values=[4, 0, 7, 1, 9, 2], queries=[[0, 2], [1, 4], [3, 10]]
[20, 2, 1]
Run checks the first 3 tests in your browser. Submit checks all 52 tests on the server, hidden ones included.