Sum of elements in matrix module some value

Revision en3, by Vasiljko, 2018-03-20 13:04:31

Given N, М and K. All nubers are  <  = 109
Define value of matrix in row i and column j as (i + j) mod K where i <  = N and j <  = M

Given Q <  = 2 * 105 queries of form Li, Lj, Ri, Rj and you need to find sum of elements in submatrix with upper left corner (Li, Lj) and lower right corner (Ri, Rj) module 109 + 7.

Some ideas?

Tags #math, #number theory

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Vasiljko 2018-03-20 13:04:31 116
en2 English Vasiljko 2018-03-17 01:52:02 6 Tiny change: ' elements from submatrix' -> ' elements in submatrix'
en1 English Vasiljko 2018-03-17 01:32:19 503 Initial revision (published)