runtime error in Little Elephant and Divisors of nov cook off?????

#include
#include
#include
#include
#include
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define FOR(i,n) for(int i=0;i<n;i++)
#define LL long int
using namespace std;
long int gcd(LL a,LL b)
{
return (b==0)?a:gcd(b,a%b);
}
int main()
{
#ifndef ONLINE_JUDGE
freopen(“input.txt”, “r”, stdin);
#endif
LL t;
sl(t);
while(t–)
{
LL n;
sl(n);
LL v[10000];
FOR(i,n)
{
sl(v[i]);
}
LL g=0;
FOR(i,n)
g=gcd(v[i],g);
if(g==1)
printf("-1\n");
else
{
LL result=g;
for(int i=2;i*i<=g;i++)
{
if(g%i==0)
{
result=i;
break;
}
}
printf("%ld\n",result);
}
}
return 0;
}

Array LL v[10000]; is too small. You should add one zero to the 10000 :slight_smile:

1 Like

thanks…:slight_smile: