SHARE
TWEET

Untitled

a guest Dec 13th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.     int prim(int n)
  5.     {
  6.      if (n<2)
  7.         return 0;
  8.      if (n==2)
  9.         return 1;
  10.      if (n%2==0)
  11.         return 0;
  12.     for (int v=3 ; v*v<=n ; v=v+2)
  13.      if(n%v==0)
  14.         return 0;
  15.         return 1;
  16.     }
  17. int main()
  18. {
  19.     int a[101][101] ;
  20.     int m, n, p=0 ;
  21.         cin >> n >> m;
  22.     for (int i=1 ; i<=n; i++)
  23.     {
  24.         for (int j=1 ; j<=m; j++)
  25.             cin>>a[i][j];
  26.     }
  27.  
  28.     for (int i=2 ; i<=n; i=i+2)
  29.     {
  30.  
  31.         for (int j=1 ; j<=m; j++)
  32.         if ( prim(a[i][j]) == 1)
  33.             p++ ;
  34.     }
  35.     cout<<p;
  36.     return 0;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top