6 solutions

  • 0
    @ 2022-4-4 17:40:22

    C++

    #include <iostream>
    #include <cmath>
    using namespace std;
    int isprime(int n)
    {
        int m = sqrt(n);
        for(int i = 2; i <= m; i++)
        {
            if(n % i == 0)  return 0;
        }
        return 1;
    }
    int main()
    {
        int T = 0;
        cin >> T;
        while(T--)
        {
            int n = 0;
            cin >> n;
            if(isprime(n))  cout << "Yes" << endl;
            else cout << "No" << endl;
        }
        return 0;
    }
    

    Information

    ID
    43
    Time
    5000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    # Submissions
    1007
    Accepted
    202
    Uploaded By