Cod sursa(job #1094252)

Utilizator CornelZCornel Z CornelZ Data 29 ianuarie 2014 03:01:27
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <iostream>

using namespace std;
bool exista_divizori_comuni(int a, int b)
{
    for(int i = min(a, b); i >= 2; i--)
    {
        if(a % i == 0 && b % i == 0)
        {
            return true;
        }
    }
    return false;
}
int main()
{
    freopen("fractii.in","r",stdin);
    freopen("fractii.out","w",stdout);
    int a;
    int solutie = 0;
    scanf("%d",&a);

    for(int i = 1; i <= a; i++)
    {
        for(int j = 1; j <= a; j++)
        {
            if(!exista_divizori_comuni(i,j)) solutie++;
        }
    }

    printf("%d",solutie);

    fclose (stdin);
    fclose (stdout);
    return 0;
}