fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. #ifndef ONLINE_JUDGE
  8. freopen("input.txt","r",stdin);
  9. freopen("output.txt","w",stdout);
  10. #endif
  11. ios_base::sync_with_stdio(0);
  12. cin.tie(0);
  13. cout.tie(0);
  14.  
  15. ll n;
  16. cin >> n;
  17. int pri[10] = {3,5,7,11,13,17,19,23,29,31};
  18. if(n<2){
  19. cout << "NO";
  20. } else if(n==2 || n==31){
  21. cout << "YES";
  22. }else if(n%2==0 && n!=2){
  23. cout << "NO";
  24. } else if(n%5 == 0 && n!=5){
  25. cout <<"NO";
  26. } else{
  27. for(int i=0 ; i<10 ; i++){
  28. if(n%pri[i]==0 && pri[i]!=n){
  29. cout << "NO";
  30. break;
  31. } else if(n%pri[i] != 0 && i==9 ){
  32. cout << "YES";
  33. }
  34. }
  35. }
  36.  
  37.  
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
YES