The Prime Cells
Practice
3.5 (47 votes)
Basic programming
Easy
Implementation
Problem
62% Success 11661 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

You are given a grid of size \(n \times n\) filled with numbers in each of its cells. Now you need to count total cells in the grid such that the sum of the numbers on its top , left , right and bottom cells is a prime number. In case there is no cell in a particular direction assume the number to be as 0.
Input
First line contains a number n as input denoting size of the grid. Next n lines contain n numbers each denoting value of the elements of the grid in each row.
Output
In the output you have to give the count of total cells as described above.
Constraints
\(2 \le n \le 100 \)
\(1 \le g[i][j] \le 100 \) where \(g[i][j]\) is the value in the grid at \(i^{th}\) row and \(j^{th}\) column.

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
15 votes
Tags:
AlgorithmsEasyHash MapsSorting
Points:20
19 votes
Tags:
ApprovedBasic ProgrammingBasics of ImplementationEasyGrammar-VerifiedImplementationReadyRecruitSimulation
Points:20
36 votes
Tags:
Ad-HocAlgorithmsApprovedBasic ProgrammingEasyImplementationOpen