Cod sursa(job #668365)

Utilizator caliman_ghCaliman Gheorghe caliman_gh Data 24 ianuarie 2012 19:53:21
Problema Algoritmul lui Euclid Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.45 kb
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;
    ifstream f("euclid2.in");
    ofstream g("euclid2.out");

    int main ()
    {
        int t, a, b, j, i, x;
        f >> t;
        for ( j=1; j<=t; j++)
        {
            f >> a >> b;
            for ( i=1; i<=min(a,b); i++ )
            {
                if ((a % i==0) && (b % i==0)) x = i;

            }
        g << x <<"\n";
        }
    }