Special matrix

3.2

25 votes
Basic Programming, C++
Problem

You have an N x M matrix, where 1 to N are rows and 1 to M are columns.

Element at the intersection of ith row and jth column is equal to F(i+j), where F(x) is equal to the number of prime divisors of x.

Determine the sum of all the elements of the matrix.

Input

  • The first line contains an integer T denoting the number of test cases.
  • For each test case, the first line contains two space-separated integers NM.

Output

For each test case, print the sum of all the elements of the matrix  in a new line.

Constraints

1T101N,M106

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The matrix and the corresponding values are:

[F(2)F(3)F(4)F(3)F(4)F(5)F(4)F(5)F(6)] = [111111112]

Hence, the sum of all the elements is 10.

Editor Image

?