Cod sursa(job #2788125)
Utilizator | Data | 25 octombrie 2021 00:11:57 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | c-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <stdio.h>
#include <stdbool.h>
int e[1000005] = {};
int main() {
freopen("fractii.in", "r", stdin);
freopen("fractii.out", "w", stdout);
int n, i, j;
long long ans = 1;
bool p[1000005] = {};
scanf("%d", &n);
for(i = 1; i <= n; ++i)
e[i] = i;
for(i = 2; i <= n; ++i)
if(p[i] == 0)
for(j = i; j <= n; j += i) {
p[j] = 1;
e[j] = e[j] / i * (i-1);
}
for(i = 2; i <= n; ++i)
ans += e[i] << 1;
printf("%lld\n", ans);
}