For GCD AND LCM question I wrote following code,

#include

using namespace std;

int main()

{

int a[1001]={},b[1001]={},n,minimum[1001]={},gcd[1001]={},lcm[1001]={};

cin>>n;

for(int i=0;i<n;i++)

{

cin>>a[i]>>b[i];

```
if(a[i]>b[i])
{
minimum[i]=b[i];
}
else
{
minimum[i]=a[i];
}
for(int j=minimum[i];j>=1;j--)
{
if(a[i]%j==0&&b[i]%j==0)
{
gcd[i]=j;
break;
}
}
lcm[i]=(a[i]*b[i])/(gcd[i]);
}
for(int i=0;i<n;i++)
{
cout<<gcd[i]<<" "<<lcm[i];
cout<<endl;
}
return 0;
```

}

here is the problem link : Contest Page | CodeChef

Can you please tell what is the error ,please.