Cod sursa(job #1605909)

Utilizator IonelChisIonel Chis IonelChis Data 19 februarie 2016 16:24:42
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#include<fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n,i,j,nrf,k,x,y,cmmdc;
int main()
{
    fin>>n;
    nrf=0;
    for(i=1;i<=n;i++)
    {
        j=1;
        while(j<=n)
        {
            x=i; y=j;
            while(x!=y)
            {
                if(x>y)
                    x-=y;
                else
                    y-=x;
            }
            cmmdc=y;
            if(cmmdc==1)
                    nrf++;
            j++;
        }
    }
    fout<<nrf;
    fin.close();
    fout.close();
    return 0;
}