Cod sursa(job #2237922)

Utilizator carol800Dima Carol Valentin carol800 Data 3 septembrie 2018 22:51:40
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <iostream>
#include <fstream>
using namespace std;
int cmmdc(int a, int b)
{
    int c=1900;
    if (a<b) swap(a, b);
    while(c>0)
    {
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
int main()
{
    ifstream fin("fractii.in");
    ofstream fout("fractii.out");
    int n, ct=0;
    fin>>n;
    for (int k=2; k<=n; k++)
    {
        for (int t=2; t<=n; t++)
        {
            if (cmmdc(k, t)==1){ ct++;}
        }
    }
    ct+=(2*n-1);
    fout<<ct;
}