Cod sursa(job #2913378)

Utilizator Patrik06Patrik Patrik06 Data 14 iulie 2022 04:48:38
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <iostream>
#include <fstream>
using namespace std;

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

    int n;
    cin >> n;
    int nr=0;
    for(int s=2; s<=n; s++)
    {
        for(int j=2; j<=n; j++)
        {
            int s_copy=s, j_copy=j;
            while(j_copy)
            {
                int r=s_copy%j_copy;
                s_copy=j_copy;
                j_copy=r;
            }
            if(s_copy==1)
                nr++;
        }
    }
    nr+=2*n-1;
    cout << nr;

    return 0;
}