Perfect Squares

Perfect Squares, we will pre calculate all perfect square & store in map.


#include<bits/stdc++.h>
using namespace std;

#define rep(a,b) for(ll ii=a;ii<b;ii++)
#define ll long long int
#define test() int tt; cin>>tt; while(tt--) 
#define fst_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'
#define lg 1000000000

map<int, int> func(map<int, int> mp)
{
  rep(0, 1000) mp[(ii+1) * (ii+1)] = 1; 
  return mp;
}

int main()
{
  map<int, int> mp;
  map<int, int>::iterator itr;
  mp = func(mp);
  
  int x, Max = INT_MIN;
  
  test()
  {
    cin>>x;
    if(mp[x]) continue;
    else if(x != 0) Max = max(Max, x);
  }
  cout<<Max;
  return 0;
}

No comments:

If you have any doubt or suggestion let me know in comment section.

Powered by Blogger.