Pagini recente » Cod sursa (job #1666492) | Cod sursa (job #701285) | Cod sursa (job #737252) | Cod sursa (job #3315528) | Cod sursa (job #3306265)
#include <iostream>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long
// Global variables
int n, m = 0;
void ReadData() {
cin >> n >> m;
}
void Solve() {
// TODO: Implement problem solution here
int minValue = min(n, m);
int maxValue = max(n, m);
while (minValue != maxValue){
maxValue -= minValue;
if (minValue > maxValue)
{
swap(minValue, maxValue);
}
}
cout << minValue << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
freopen("euclid2.in", "r", stdin);
freopen("euclid2.out", "w", stdout);
int t = 1;
cin >> t; // Uncomment for multiple test cases
while (t--) {
ReadData();
Solve();
}
return 0;
}