Cod sursa(job #2156799)

Utilizator 24601Dan Ban 24601 Data 9 martie 2018 00:13:34
Problema Algoritmul lui Euclid Scor 100
Compilator c Status done
Runda Arhiva educationala Marime 0.55 kb
#include <stdio.h>
#include <string.h>

#define SIZE 100000

static const char *fin = "euclid2.in", *fout = "euclid2.out";
static long long v[SIZE+1];

static unsigned long cmmdc(unsigned long a, unsigned long b)
{
    if (a % b)
        return cmmdc(b, a % b);
    return b;
}

int main(void)
{
    unsigned n;
    unsigned long a, b;

    memset(v, 0x01, sizeof v);

    freopen(fin, "r", stdin);
    freopen(fout, "w", stdout);

    scanf("%u", &n);
    while (n--) {
        scanf("%lu %lu", &a, &b);
        printf("%lu\n", cmmdc(a, b));
    }

    return 0;
}