fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. void solve() {
  7. int n;
  8. cin >> n;
  9.  
  10. long long total = 0;
  11. for (int i = 0; i < n; ++i) {
  12. int a;
  13. cin >> a;
  14. total += a;
  15. }
  16.  
  17. long long root = sqrt(total);
  18. if (root * root == total) {
  19. cout << "YES\n";
  20. } else {
  21. cout << "NO\n";
  22. }
  23. }
  24.  
  25. int main() {
  26. ios::sync_with_stdio(false);
  27. cin.tie(nullptr);
  28.  
  29. int t;
  30. cin >> t;
  31. while (t--) {
  32. solve();
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5300KB
stdin
5
1
9
2
14 2
7
1 2 3 4 5 6 7
6
1 3 5 7 9 11
4
2 2 2 2
stdout
YES
YES
NO
YES
NO