Pagini recente » Cod sursa (job #2893401) | Cod sursa (job #1092039) | Cod sursa (job #240311) | Cod sursa (job #2953227) | Cod sursa (job #341966)
Cod sursa(job #341966)
#include <iostream>
FILE *f = fopen("mins.in", "r"), *g = fopen("mins.out", "w");
long nr = 0;
int n, m;
int cmmdc(int a, int b)
{
int x;
if (a < b) {x = a;a = b;b = x;}
while (b)
{x = b;
b = a % b;
a = x;
}
x = a;
return x;
}
int main()
{
fscanf(f, "%d %d", &n, &m);
fclose(f);
for (int i = 1; i < n; ++i)
for (int j = 1; j < m; ++j)
{
if (cmmdc(i, j) == 1) ++nr;
}
fprintf(g, "%ld", nr);
fclose(g);
return 0;
}