Pagini recente » Cod sursa (job #55667) | Cod sursa (job #954892) | Diferente pentru problema/rombulum intre reviziile 18 si 2 | Cod sursa (job #2647540) | Cod sursa (job #2168907)
#include <cstdio>
using namespace std;
int gcd(int x, int y)
{
int r;
while(y>0)
{
r=x%y;
x=y;
y=r;
}
return x;
}
int i, t, a, b;
int main()
{
freopen("pc.in", "r", stdin);
freopen("pc.out", "w", stdout);
scanf("%d", &t);
for(i=1; i<=t; i++)
{
scanf("%d%d", &a, &b);
printf("%d\n", gcd(a, b));
}
fclose(stdin);
fclose(stdout);
return 0;
}