URI Collectable Cards
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
int a,b,r=1;
cin >> a >> b;
if(a > b)
{
swap(a,b);
}
// gcd
while(r)
{
r = b % a;
b = a;
a = r;
}
cout << b << endl;
}
return 0;
}
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
int a,b,r=1;
cin >> a >> b;
if(a > b)
{
swap(a,b);
}
// gcd
while(r)
{
r = b % a;
b = a;
a = r;
}
cout << b << endl;
}
return 0;
}
Comments
Post a Comment