Cod sursa(job #763437)

Utilizator kakkarotFaur Catalin kakkarot Data 2 iulie 2012 11:20:27
Problema Algoritmul lui Euclid Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.46 kb
#include <fstream>

using namespace std;

long long Euclid(long long a,long long b)
{
   long long r;
   while( (r=a%b)!=0)
   {
      a=b;
	  b=r;
   }
   return b;
}

int main()
{
   int t;
   long long a,b;
   
   ifstream cin("euclid2.in");
   ofstream cout("euclid2.out");
   cin >> t;
  
   for(int i=0;i<t;i++)
   {
       cin >> a >> b;
       cout << Euclid(a,b) << endl;
   }
   cin.close();
   cout.close();
   return 0;
}