Cod sursa(job #1880359)

Utilizator ionut270Oancea Ionut Eugen ionut270 Data 15 februarie 2017 18:23:04
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include<iostream>
#include <fstream>
using namespace std;
int main()
{
    int x,y,n,i,j,v=0;
    ifstream f("fractii.in");
    f>>n;
    f.close();
    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
        {
            x=i;y=j;
            while(x!=y)
                if(x>y)
                    x=x-y;
                else
                    y=y-x;
            if(x==1)
                v=v+1;
        }
        ofstream o("fractii.out");
        o<<v;
        return 0;
}