Cod sursa(job #682786)
| Utilizator | Data | 19 februarie 2012 15:07:12 | |
|---|---|---|---|
| Problema | Fractii | Scor | 71 |
| Compilator | cpp | Status | done |
| Runda | penalty_testing1 | Marime | 0.49 kb |
#include <cassert>
#include <cstdio>
const int MAX_N = 1000005;
int n;
int v[MAX_N];
int main() {
assert(freopen("fractii.in", "r", stdin));
assert(freopen("fractii.out", "w", stdout));
assert(scanf("%d", &n) == 1);
for (int i = 2; i <= n; ++i)
v[i] = i - 1;
for (int i = 2; i <= n; ++i)
for (int j = 2 * i; j <= n; j += i)
v[j] -= v[i];
long long ans = 1;
for (int i = 2; i <= n; ++i)
ans += 2 * v[i];
printf("%lld\n", ans);
}
