Okay, this one’s interesting …

Here is a problem from school aka beginner section of codechef. Problem is simple. Find gcd and lcm . That’s it. Here is the problem.

I submitted 2 solutions . Solution 1 got accepted while Solution 2 gets rejected. What’s the difference ? Only of int and long long . Int one gets accepted (solution 1) while long long one got rejected . (solution 2)

```
#include<stdio.h>
int gcd(int a , int b)
{
if(a==0)
return b;
return gcd(b%a , a);
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b,k;
scanf("%d%d",&a,&b);
k=gcd(a,b);
printf("%d %d\n",k,(a*b)/k);
}
return 0;
}
```

```
#include<stdio.h>
long long gcd(long long a , long long b)
{
if(a==0)
return b;
return gcd(b%a , a);
}
int main()
{
long long t;
scanf("%lld",&t);
while(t--)
{
long long a,b,k;
scanf("%lld%lld",&a,&b);
k=gcd(a,b);
printf("%lld %lld\n",k,(a*b)/k);
}
return 0;
}
```

So, who has a explanation now ?