Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <bitset>
- #include <vector>
- #define DN 10000005
- #define LL long long
- using namespace std;
- int n;
- LL nr;
- vector<LL> pr;
- bitset<DN> isp;
- void c() {
- for(int i=2; i*1LL*i<DN; ++i) if(!isp[i]) {
- pr.push_back(i);
- for(int j=i*i; j<DN; j+=i) isp[j]=1;
- }
- }
- bool ok(LL nr) {
- for(int i=0; i<pr.size(); ++i) if(pr[i]*pr[i]==nr) return 1;
- return 0;
- }
- int main()
- {
- c();
- cin>>n;
- for(int i=1; i<=n; ++i) {
- cin>>nr;
- if(nr<4) {
- cout<<"NO\n";
- continue;
- }
- if(ok(nr)) cout<<"YES\n";
- else cout<<"NO\n";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment