Cod sursa(job #2313544)

Utilizator LascoDaniilDanielDFS LascoDaniil Data 7 ianuarie 2019 02:04:52
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.86 kb
#include <bits/stdc++.h>
#define  max(a,b)(( a>b) ? a : b)

using namespace std;

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

unsigned gcd_recursive(unsigned a, unsigned b)
{
    if (b)
        return gcd_recursive(b, a % b);
    else
        return a;
}

int main()
{
    int n, contor=0, i,j;
    fin >> n;
        if(n<1){
          return 0;
        }
    /*
    int contor = 0;
    for(int i = 1; i <=n ; i ++){
        for(int j=1; j <= n ; j++){
            if(gcd_recursive(i,j) == 1){
                contor ++;
            }
        }
    }
    */
    i = 1;
    while(i<=n){
        j= 1;
            while(j <= n ){
                if(gcd_recursive(i,j) == 1){
                contor ++;
            }
                j++;
            }

        i++;
    }

    fout << contor ;
    return 0;
}