Pagini recente » Cod sursa (job #250908) | Cod sursa (job #17989) | Cod sursa (job #879180) | Cod sursa (job #904122) | Cod sursa (job #1169018)
#include <stdio.h>
long x,y,n;
using namespace std;
inline long cmmdc(long x,long y)
{
if (x==y)
return x;
if (!x)
return y;
if (!y)
return x;
if (x>y)
return cmmdc(x%y,y);
else
return cmmdc(x,y%x);
}
int main()
{
freopen ("euclid2.in","r",stdin);
freopen ("euclid2.out","w",stdout);
scanf ("%ld",&n);
for (long i=1;i<=n;i++)
{
scanf ("%ld %ld",&x,&y);
printf ("%ld\n",cmmdc(x,y));
}
return 0;
}