Cod sursa(job #2452186)
Utilizator | Data | 29 august 2019 20:09:13 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("euclid2.in");
ofstream fout ("euclid2.out");
long long a, b, r, test;
int main (){
fin>>test;
for(int t=1; t<=test; t++){
fin>>a;
fin>>b;
if(a < b)
swap(a, b);
while(b != 0){
r=a%b;
a=b;
b=r;
}
fout<<a<<"\n";
}
return 0;
}