Cod sursa(job #1461634)

Utilizator StefanCeLmIcStefan Dumitru StefanCeLmIc Data 16 iulie 2015 04:43:56
Problema Algoritmul lui Euclid Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
#include <iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream in("euclid2.in");
ofstream out("euclid2.out");
int main()
{
    long long i,j,a,b,r,x=-1,k,n,v[100000];
    in>>n;
    for(k=1;k<=n;k++)
    {


    in>>i;
    in>>j;
    if(i>j)
    {
        a=i;
        b=j;
    }
    else
    {
        a=j;
        b=i;
    }
    r=a%b;
   while(r)
   {
       a=b;
       b=r;
       r=a%b;
   }
   out<<b;
    }


   return 0;
}