4 solutions

  • 0
    @ 2024-11-8 13:59:45

    #include #include using namespace std; int isprime(long long k) { long long i; if(k<=1){ return 0; } else if(k<=3){ return 1; } else if(k%20||k%30){ return 0; } else{ for(i=5;ii<=k;i+=6){ if(k%i==0||k%(i+2)==0){ return 0; } } } return 1; } int main() { int t; long long a,b; cin>>t; while(t--){ cin>>a>>b; if(isprime(ab)){ cout<<"YES\n"; } else{ cout<<"NO\n"; } } return 0; }

    Information

    ID
    22
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    723
    Accepted
    104
    Uploaded By