Cod sursa(job #477415)

Utilizator radu.comanRadu Coman - UPB radu.coman Data 14 august 2010 15:19:19
Problema Algoritmul lui Euclid Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.51 kb
#include <iostream>
#include <fstream>
#include <ctime>

using namespace std;

int main()
{
	clock_t start = clock();
	ifstream in ("euclid2.in");
	ofstream out ("euclid2.out");
	int t, x, y, aux;
	in >> t;
	for (; t; --t)
	{
		in >> x >> y;
		if (x == 0) {out << y << "\n"; continue; }
		while (y > 0)
		{
			aux = x;
			x = y;
			y = aux % x;
		}
		out << x << "\n";
	}
	in.close();
	out.close();
	clock_t stop = clock();
	cout << (double) (stop-start) / CLOCKS_PER_SEC << endl;
	return 0;
}