fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. bool nt(long long n) {
  5. if (n <= 1) return false;
  6. if (n == 2 || n == 3) return true;
  7. if (n % 2 == 0 || n % 3 == 0) return false;
  8. for (long long i = 5; i * i <= n; i += 6) {
  9. if (n % i == 0 || n % (i + 2) == 0) return false;
  10. }
  11. return true;
  12. }
  13.  
  14. int main() {
  15. ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  16. long long n; cin >> n;
  17. cout << (nt(n) ? "YES" : "NO");
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
NO