Cod sursa(job #639899)
| Utilizator | Data | 24 noiembrie 2011 11:22:30 | |
|---|---|---|---|
| Problema | Fractii | Scor | 0 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <stdio.h>
#include <stdlib.h>
#define LEN 10000001
int n;
unsigned long long count, i, j;
int
main(void)
{
char* phi = (char *)malloc(LEN * sizeof(char));
freopen("fractii.in", "r", stdin);
scanf("%d", &n);
for (i = 1; i <= n; i++)
phi[i] = i;
for (i = 2; i <= n; i++)
{
if (phi[i] == i)
for (j = i; j <= n; j += i)
phi[j] /= i, phi[j] *= (i - 1);
count += (long long)2 * phi[i];
}
fprintf(freopen("fractii.out", "w", stdout), "%lld", count + 1);
return 0;
}
