Cod sursa(job #1205113)

Utilizator oopsSoare George oops Data 5 iulie 2014 12:22:59
Problema Algoritmul lui Euclid Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
//#include "stdafx.h"
#include<iostream>
#include<stdio.h>

#define ll long long
using namespace std;

ll cmmdc(ll a, ll b)
{
	ll d=1;
	while (b)
	{
		d = a%b;
		a = b;
		b = d;
	}
	return a;
}

int main()
{
	ll t;
	freopen("euclid2.in", "r", stdin);
	freopen("euclid2.out", "w", stdout);
	scanf("%lld",&t);
	while (t--)
	{
		ll a, b;
		scanf("%lld %lld", &a, &b);
		printf("%lld\n", cmmdc(a, b));
	}

	return 0;
}