fork download
  1. // Bài 2: Phân tích thừa số nguyên tố (chưa đếm YES)
  2. #include<bits/stdc++.h>
  3. #define f1(i, n) for(int i=1;i<=n;++i)
  4. #define f0(i, n) for(int i=0;i<n;++i)
  5. #define ull unsigned long long
  6. #define ll long long
  7. #define rev(a) reverse(a.begin(),a.end())
  8. #define all(x) x.begin(),x.end()
  9. #define so(A, n) sort(A+1, A+n+1)
  10. using namespace std;
  11. const int maxn = 1e6 + 1;
  12. using namespace std;
  13. map<int, int> mp;
  14. int A[maxn];
  15. int main() {
  16. int n;
  17. cin >> n;
  18. f1(i, n) {
  19. bool check = true;
  20. cin >> A[i];
  21. int a = A[i];
  22. for (int j = 2; j <= sqrt(a); ++j) {
  23. while (a % j == 0) {
  24. a /= j;
  25. mp[j]++;
  26. }
  27. }
  28. if (a > 1) {
  29. mp[a]++;
  30. }
  31. for(auto x:mp){
  32. if(x.second % 2 != 0){
  33. cout<<"NO ";
  34. check = false;
  35. break;
  36. }
  37. }
  38. if(check){
  39. cout<<"YES ";
  40. }
  41. }
  42. }
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
Standard output is empty