Cod sursa(job #2634046)
Utilizator | Data | 9 iulie 2020 17:27:03 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n, phi[1000005];
long long total;
int main() {
fin >> n;
for (int i = 1; i <= n; ++i)
phi[i] = i - 1;
for (int i = 2; i <= n; ++i) {
total += phi[i];
for (int j = i * 2; j <= n; j += i)
phi[j] -= phi[i];
}
fout << total * 2 + 1;
return 0;
}