NT01


Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 512M

Problem type

Cho số nguyên dương \(n\).

Yêu cầu: Cho biết số \(n\) có phải là số nguyên tố không?

Input

  • Gồm một dòng chứa số nguyên dương \(n(|n|≤10^{12} ).\)

Output

  • Ghi \(YES\) nếu \(n\) là số nguyên tố, ngược lại ghi \(NO\).

Sample Input

7

Sample Output

YES

Sample Input

6

Sample Output

NO

Comments


  • 0
    B2_Nguyen_Bach_Long_Nhat  commented on Sept. 6, 2025, 7:07 a.m.

    include <bits/stdc++.h>

    define ll long long

    define fr(i,a,b) for(int i=a;i<=b;i++)

    using namespace std; ll n; void messi() { cin>>n;} int NTO(ll x) {ll d=0; fr(i, 1, sqrt(x)) if (x%i==0) { d++; if(i!=x/i) d++; } if (d==2) return 1; else return 0; } int main() { messi(); if(NTO(n)==1) cout<<"YES"; else cout<<"NO"; }