Special matrix
Practice
3.2 (25 votes)
Basic programming
C++
Problem
46% Success 7994 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You have an N x M matrix, where 1 to N are rows and 1 to M are columns.
Element at the intersection of \(i^{th}\) row and \(j^{th}\) 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 N, M.
Output
For each test case, print the sum of all the elements of the matrix in a new line.
Constraints
\(1 ≤ T ≤ 10\)
\(1 ≤ N, M ≤10^6\)
Sample Input
1 3 3
Sample Output
10
Explanation
The matrix and the corresponding values are:
\(\begin{bmatrix} F(2) & F(3) & F(4)\)
\(F(3) & F(4) & F(5)\)
\(F(4) & F(5) & F(6)\)
\(\end{bmatrix}\)
= \(\begin{bmatrix} 1 & 1 & 1\)
\(1 & 1 & 1\)
\(1 & 1 & 2\)
\(\end{bmatrix}\)
Hence, the sum of all the elements is 10.
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Submissions
Please login to view your submissions
Similar Problems
Points:20
30 votes
Tags:
Basic ProgrammingBasics of ImplementationCombinatoricsEasyImplementation
Points:20
178 votes
Tags:
GeometryHiringApprovedEasy
Points:20
6 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementation
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor