Cod sursa(job #3260812)

Utilizator liviu5_mlPopescu Ion liviu5_ml Data 3 decembrie 2024 19:12:31
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <bits/stdc++.h>

using namespace std;

int n,k;

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

bool check(int a, int b) {
    int r = 0;
    while(b) {
        r = a%b;
        a = b;
        b = r;
    }
    return a == 1;
}

int main()
{
    in >> n;

    for(int i = 1;i<=n;i++) {
        for(int j = 1;j<=n;j++) {
            if(check(i,j)) k++;
        }
    }

    out << k;

    return 0;
}