fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n,m,k=0,p,k1=0,l;
  7. cin>>n>>m;
  8. for(int i=n;i<=m;i++)
  9. {
  10. p=0,l=0;
  11. for (int j=1;j<=i;j++)
  12. {
  13. if(i>n && i<m)
  14. {
  15. if(i%j==0)
  16. p++;
  17. }
  18. else if(i==n || i==m)
  19. {
  20. if(i%j==0)
  21. l++;
  22. }
  23.  
  24. }
  25. if(p==2)
  26. k++;
  27. if(l==2)
  28. k1++;
  29. }
  30.  
  31. if(k1==2 && k==0)
  32. cout<<"YES";
  33. else
  34. cout<<"NO";
  35. }
Success #stdin #stdout 0s 4416KB
stdin
2 4
stdout
NO