Posted on

Description

Submission

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int N; cin >> N;
    for(int i = 0; i < N; ++i) {
        int n; cin >> n;
        int isPrime = true;
        if(n == 1) {
            cout << "Not prime\n";
            continue;
        }
        if(n == 2 || n == 3) {
            cout << "Prime\n";
            continue;
        }
        for(int j = 2; j < sqrt(n) + 1; ++j) {
            if(n % j == 0) {
                cout << "Not prime\n";
                isPrime = false;
                break;
            } 
        }
        if(isPrime) cout << "Prime\n";
    }
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *