Mai intai trebuie sa te autentifici.
Cod sursa(job #595990)
Utilizator | Data | 15 iunie 2011 02:03:34 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include <stdio.h>
int main(){
long int n,j,i;
freopen ("fractii.in", "r", stdin);
freopen ("fractii.out", "w", stdout);
scanf ("%ld", &n);
long int a[n];
long long s = 0;
for (j = 1; j <= n; j++)
a[j] = j - 1;
for (i = 2; i <=n; i ++)
for (j = 2*i;j <= n;j +=i)
a[j] -= a[i];
for (i = 1; i <= n; i++)
s = s + a[i];
printf ("%lld", s*2 + 1);
return 0;
}