Is It a Perfect Square?


This is a companion discussion topic for the original entry at https://toph.co/p/is-it-perfect-square

#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,y,z,i,j;
cin>>x;
for(i=0;i<x;i++)
{
int count=0;
cin>>y;
for(j=0;j<y;j++)
{
cin>>z;
int a=sqrt(z);
if(z-(a*a)==0)
count++;
}
if(count==y)
cout<<“YES”<<endl;
else
cout<<“NO”<<endl;
}

}
what’s the problem this code?

This problem has some problems. I think the processing algorithm is not correct.

Code

Can anyone tell me what is wrong with the code?
It seems to be outputting the wrong answer on test 2``

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

int main()
{
int t,n,c=0,a[1000];
double div,m;
cin >> t;
while(t–)
{
cin >> n;
for(int i=0;i<n;i++)
{
cin >> a[i];
m=sqrt(a[i]);
div=a[i]/m;
if(m!=(int)div)
{
c++;
break;
}
}
if(c!=0)cout<<“NO”<<endl;
else cout<<“YES”<<endl;
c=0;div=0;m=0;
}
}

What is problem??
2th test case Runtime Error

#include<stdio.h>
int main()
{
long long int T,i,n,j,l;
scanf("%lld",&T);
for(i=1; i<=T; i++){

    scanf("%lld",&n);
long long int m=1,h;
        double k,l;
    for(j=1; j<=n; j++){
        scanf("%lld",&h);
        m=m*h;
    }
    k=sqrt(m);
    l=m-(k*k);
    if(l==0){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

}

}
After running it,with the sample cases my compiler says YES NO NO but toph says YES NO YES.How is it possible ??? Plz, hlp.
Matha gorom hoye jacche. Continuously 4 days I have noticed that kind of problem in different kinds of problems in toph.co