Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n,m,v[101][101],j,semafor=0,nr=0,i,k;
  8. cin>>n>>m;
  9. for(i=1;i<=n;i++){
  10. for(j=1;j<=m;j++){
  11. cin>>v[i][j];
  12. }
  13. }
  14. for(i=2;i<=n;i=i+2){
  15. for(j=1;j<=m;j++){
  16. semafor=0;
  17. for(k=2;k * k <= v[i][j] ;k++){
  18. if(v[i][j]%k==0){
  19. semafor=1;
  20. }
  21. }
  22. if(v[i][j] == 1)
  23. semafor = 1;
  24. if(semafor==0){
  25. nr++;
  26. }
  27.  
  28. }
  29. }
  30. cout<<nr;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement