Cod sursa(job #2468927)

Utilizator Iustin01Isciuc Iustin - Constantin Iustin01 Data 6 octombrie 2019 11:38:44
Problema Algoritmul lui Euclid Scor 60
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream in("euclid2.in");
ofstream out("euclid2.out");

int cmmdc(int a, int b){
    while(a != b)
        if(a < b) b-=a;
        else a -= b;
    return a;
}

int main(){
    int t,mat[100001][2];
    in>>t;
    for(int i = 0; i < t; i++)
    for(int j = 0; j < 2; j++){
        in>>mat[i][j];
        if(j == 1) out<<cmmdc(mat[i][0] , mat[i][1])<<"\n";
    }
}