Advertisement
momo2345

perfectSquare

May 6th, 2021
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define endl '\n'
  5. #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. #define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
  7.  
  8. map<long long, bool> isPerSqr;
  9.  
  10. int main()
  11. {
  12.     optimize();
  13.  
  14.     int lim = 32e4;
  15.     for ( int i = 1; i <= lim; i++ ) {
  16.         isPerSqr[1LL*i*i] = 1;
  17.     }
  18.  
  19.     int T;
  20.     cin >> T;
  21.     while(T--) {
  22.         long long n;
  23.         cin >> n;
  24.         if ( isPerSqr[n] ) cout << "YES\n";
  25.         else cout << "NO\n";
  26.     }
  27.  
  28.  
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement