using namespace std;
int GCD(vector& gcd,int small)
{
if(gcd.size()>1)
return 0;
else
{
if(gcd[0]==1)
return 0;
else
return -1;
}
}
int main()
{
int T;
cin>>T;
while(T–)
{
unsigned int N;
int num,i;
cin>>N;
vector A;
A.reserve(N);
for(i=0;i<N;i++)
{
cin>>num;
A.push_back(num);
// cout<<"\t";
}
int smallest=A[0];
for(i=1;i<A.size();i++)
{
if(smallest>A[i])
smallest=A[i];
}
for(i=0;i<A.size();i++)
{
if(((A[i]%smallest==0)&&(A[i]!=smallest))||A[i]==0)
A.erase(A.begin()+i);
}
cout<<GCD(A,smallest)<<endl;
}
return 0;
}
Its shwoing WA where as the answer is correct as i ahve checked in ideone also, can plz anyone point out wheres the problem is?