Cod sursa(job #92257)
| Utilizator | Data | 14 octombrie 2007 19:38:52 | |
|---|---|---|---|
| Problema | Fractii | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <stdio.h>
#include <math.h>
long n;
long gcd(long a, long b) {
long c = 0;
while (b != 0) {
c = a % b;
a = b;
b = c;
}
return a;
}
int main() {
freopen("fractii.in", "r", stdin);
freopen("fractii.out", "w", stdout);
scanf("%ld", &n);
long i, j;
long long sol = 0;
long a, b, c;
for (i = 1; i <= n; ++i) {
for (j = 1; j <= n; ++j) {
a = i, b = j;
while (b != 0) {
c = a % b;
a = b;
b = c;
}
if (a == 1) ++sol;
}
}
printf("%lld\n", sol);
return 0;
}