Last active
October 24, 2019 20:41
-
-
Save sofhiasouza/7e045691ebbafc258fffad10a5af3336 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int gcd(int a, int b) | |
{ | |
if(b == 0) return a; | |
return gcd(b, a%b); | |
} | |
int main() | |
{ | |
int n; | |
cin >> n; //leio o n | |
while(n--) //rodo os n casos | |
{ | |
int f1, f2; | |
cin >> f1 >> f2; //leio o f1 e o f2 | |
if(f1 < f2) swap(f1, f2); //coloco f1 como o maior e f2 como o menor | |
int resp = gcd(f1, f2); //calculo o mdc de f1 e f2 | |
cout << resp << "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment