#C2469. Prime Matrix Sum

    ID: 45788 Type: Default 1000ms 256MiB

Prime Matrix Sum

Prime Matrix Sum

Given an (n \times m) matrix of integers, your task is to compute the sum of all prime numbers in the matrix. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.

Note that matrix elements can be negative, zero, or positive. Only include those numbers that are prime in your summation.

inputFormat

The first line contains two integers (n) and (m), denoting the number of rows and columns respectively. Each of the following (n) lines contains (m) space-separated integers representing the matrix elements.

outputFormat

Output a single integer which is the sum of all prime numbers in the matrix.## sample

3 3
2 3 4
5 6 7
8 9 10
17