Cod sursa(job #2823888)

Utilizator AndrewAndrooNecula Andrei AndrewAndroo Data 29 decembrie 2021 22:39:37
Problema Fractii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    ifstream in;
    in.open("fractii.in");
    ofstream out;
    out.open("fractii.out");

    unsigned int n, x, c = 0;

    in >> n;

    for (unsigned int u = 1; u <= n; u++)
    {
        for (unsigned int d = 1; d <= n; d++)
        {
            x = u + 1;

            while (1)
            {
                x--;
                if (u%x == 0 && d%x == 0)
                    break;
            }

            if (x == 1)
                c++;
        }
    }

    out << c;

    return 0;
}