Cod sursa(job #2641175)
| Utilizator | Data | 10 august 2020 13:27:36 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
//#include "pch.h"
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#define nmax 2000005
using namespace std;
ifstream f("euclid2.in");
ofstream o("euclid2.out");
int a, b;
int t;
int euclid(int x, int y)
{
if (x < y)
{
swap(x, y);
}
while (y)
{
int rest = x % y;
x = y;
y = rest;
}
return x;
}
int main()
{
f >> t;
while (t--)
{
f >> a >> b;
o << euclid(a, b) << "\n";
}
}