Cod sursa(job #2194574)
| Utilizator | Data | 13 aprilie 2018 19:21:35 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
// euclidalg.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("euclid2.in");
ofstream out("euclid2.out");
int t;
pair <int, int> cmd;
inline int gcd(int a, int b)
{
if (!b) return a;
return gcd(b, a % b);
}
int main()
{
in >> t;
for (int i = 1; i <= t; i++)
{
in >> cmd.first >> cmd.second;
out << gcd(cmd.first, cmd.second) << '\n';
}
return 0;
}
