Cod sursa(job #2931844)

Utilizator simooBita Simone simoo Data 1 noiembrie 2022 01:22:39
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.61 kb
#include<iostream>
#include<fstream>

using namespace std;

ifstream fin("fractii.in");
ofstream fout("fractii.out");


bool verif(int a, int b)
{
    while(a!=b)
    {
        if(a>b)
            a = a-b;
        else
            b = b-a;

    }
    if(a == 1)
    {
        return true;
    }
    else
    {
        return false;
    }
}


int n, i, j, cnt = 0;



int main()
{
    fin>>n;
    for(i = 1; i<=n; ++i)
    {
        for(j = 1; j<=n; ++j)
        {
            if(verif(i, j))
            {
                cnt++; 
            }
        }
    }
    fout<<cnt;
}