Tap here to switch tabs
Problem
Submissions

Problem: Sum Of Special Evenly-Spaced Elements In Array

Try to solve the Sum Of Special Evenly-Spaced Elements In Array problem.

Statement

You are given an integer array nums and a 2D\text{2D} integer array queries, where queries[i] =[xi,yi]= [x_i, y_i].

For each query queries[i], calculate the sum of all elements nums[j] where j=xi+k×yij = x_i + k \times y_i for all non negative integers kk such that j<j < nums.length.

Return an array containing the answer for each query modulo 109+710^9 + 7.

Constraints:

  • n ==== nums.length

  • 1≤1 \leq n ≤5×104\leq 5 \times 10^4

  • 0≤0 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq queries.length ≤1.5×105\leq 1.5 \times 10^5

  • 0≤0 \leq x_i << n

  • 1≤1 \leq y_i ≤5×104\leq 5 \times 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum Of Special Evenly-Spaced Elements In Array

Try to solve the Sum Of Special Evenly-Spaced Elements In Array problem.

Statement

You are given an integer array nums and a 2D\text{2D} integer array queries, where queries[i] =[xi,yi]= [x_i, y_i].

For each query queries[i], calculate the sum of all elements nums[j] where j=xi+k×yij = x_i + k \times y_i for all non negative integers kk such that j<j < nums.length.

Return an array containing the answer for each query modulo 109+710^9 + 7.

Constraints:

  • n ==== nums.length

  • 1≤1 \leq n ≤5×104\leq 5 \times 10^4

  • 0≤0 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq queries.length ≤1.5×105\leq 1.5 \times 10^5

  • 0≤0 \leq x_i << n

  • 1≤1 \leq y_i ≤5×104\leq 5 \times 10^4