Cod sursa(job #998880)

Utilizator KiralyCraftKiraly Alex KiralyCraft Data 18 septembrie 2013 17:10:31
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <iostream>
#include <fstream>
using namespace std;
long long cmmdc(long long x,long long y)
{

    while (x!=y)
        if (x>y)
            x = x - y;
        else
            y = y - x;
    return x;

}
int main()
{
    fstream fin("fractii.in",ios::in);
    fstream fout("fractii.out",ios::out);
    int n;
    long long found=0;
    fin >> n;
    for (long long i=1;i<=n;i++)
    {
        for (long long j=1;j<=n;j++)
        {
            if (cmmdc(i,j)==1)
            {
                found++;
            }
        }
    }
    fout << found;
}