How to solve SQRSUBMA?

Could anyone give a brief solution?

bump

Calculating total submatrix having sum x is equivalent to find no of i1, j1, i2, j3 having length * (sum(i1, j1) + sum(i2, j2)) = x. where lenght is the side of the square.Since it is equal to x we can say that x should be divisble by length.so we can calculate all types of possible length by factorisation.once we find out the length we can also calculate the total no of pair subarrays having sum = x / length.