Cod sursa(job #1596169)

Utilizator andrei1299Ghiorghe Andrei Alexandru andrei1299 Data 10 februarie 2016 20:38:25
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <bits/stdc++.h>

using namespace std;
int n;

int main()
{
    int i,j,k,aux,y,x,ok=0;
    ifstream fin("fractii.in");
    fin>>n;
    fin.close();
    for(i=1;i<=n;i++)
        for(j=i;j<=n;j++)
    {
        k=1;
        x=i;y=j;
        while(k==1)
            if(!y) k=0;
                else
                {
                    aux=x;
                    x=y;
                    y=aux%y;
                }
        if(x<=1) {ok++;}

    }
    ofstream fout("fractii.out");
    fout<<(ok*2)-1;
    fout.close();

    return 0;
}