时间复杂度O(√n)
#include<bits/stdc++.h> #include<iostream> using namespace std; int n; int main(){ cin>>n; if(n<2){ cout<<"Not Prime"<<endl; return 0; } for(int i=2;i*i<=n;i++){ if(n%i==0){ cout<<"Not Prime"<<endl; return 0; } } cout<<"Prime"<<endl; return 0; }