Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- using namespace std;
- vector <bool> res;
- int main()
- {
- int n=1000001;
- vector<char> prime (n+1, true);
- prime[0] = prime[1] = false;
- for (int i=2; i<=n; ++i)
- if (prime[i])
- if (i * 1ll * i <= n)
- for (int j=i*i; j<=n; j+=i)
- prime[j] = false;
- long long t,q;
- cin >> t;
- for (int i=0;i<t;++i)
- {
- cin >> q;
- double s = sqrt ((double)(q));
- if (s==(long long)s)
- {
- if (prime[(long long)s]==true) { res.push_back (true); continue;}
- }
- res.push_back(false);
- }
- for (unsigned i=0;i<res.size();i++)
- if (res[i]) cout <<"YES" << endl;
- else cout << "NO"<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment