Cod sursa(job #2182973)

Utilizator mouse_wirelessMouse Wireless mouse_wireless Data 22 martie 2018 18:45:18
Problema Algoritmul lui Euclid Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.74 kb
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define mp make_pair
#define CHECK(x) if(!(x)) return false;
typedef pair<int, int> pii;

#ifdef INFOARENA
#define ProblemName "euclid2"
#endif

#define MCONCAT(A, B) A B
#ifdef ProblemName
#define InFile MCONCAT(ProblemName, ".in")
#define OuFile MCONCAT(ProblemName, ".out")
#else
#define InFile "fis.in"
#define OuFile "fis.out"
#endif

int gcd(int a, int b) {
  while (b) {
    int aux = a % b;
    a = b;
    b = aux;
  }
  return a;
}

int main() {
  freopen(InFile, "r", stdin);
  freopen(OuFile, "w", stdout);
  int T;
  scanf("%d", &T);
  while (T--) {
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", gcd(a, b));
  }
  return 0;
}