Pagini recente » Istoria paginii runda/6d_seb_sapatamanaaltfel/clasament | Cod sursa (job #2842513) | Cod sursa (job #332113) | Cod sursa (job #2177424) | Cod sursa (job #3245928)
//https://infoarena.ro/problema/fractii
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int cmmdc(int a, int b);
int main()
{
int n, cnt = 0;
fin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (cmmdc(i, j) == 1)
cnt++;
fout << cnt;
return 0;
}
int cmmdc(int a, int b)
{
int aux = a % b;
while (aux)
{
a = b;
b = aux;
aux = a % b;
}
return b;
}