Cod sursa(job #2854120)
Utilizator | Data | 20 februarie 2022 22:13:03 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f ("fractii.in");
ofstream g ("fractii.out");
const int M = 1e6 + 1;
int main() {
int a[M], n;
unsigned long long s = 0;
f >> n;
for (int i = 2; i <= n; i ++) a[i] = i;
for (int i = 2; i <= n; i ++) if (a[i] == i) {a[i] --; for (int j = 2 * i; j <= n; j += i) a[j] = a[j] / i * (i - 1);}
for (int i = 2; i <= n; i ++) s += a[i];
s *= 2; s ++;
g << s;
return 0;
}