Cod sursa(job #3349029)

Utilizator agaman1792Alex Gaman agaman1792 Data 25 martie 2026 00:03:33
Problema A+B Scor 0
Compilator c-64 Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <stdio.h>

static long gcd(long a, long b)
{
    while (b != 0) {
        long t = b;
        b = a % b;
        a = t;
    }
    return a;
}

int main(void)
{
    FILE *fin  = fopen("cmmdc.in",  "r");
    FILE *fout = fopen("cmmdc.out", "w");

    long a, b;
    fscanf(fin, "%ld\n%ld", &a, &b);

    long result = gcd(a, b);
    fprintf(fout, "%ld\n", result == 1 ? 0 : result);

    fclose(fin);
    fclose(fout);
    return 0;
}