Cod sursa(job #2766098)
| Utilizator | Data | 31 iulie 2021 06:14:40 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream>
#include <vector>
using namespace std;
int n, i, j;
long long solutie = 1;
ifstream f("fractii.in");
ofstream g("fractii.out");
int main() {
vector<int> phi;
f >> n;
for (i = 0; i <= n; ++i) phi.push_back(i);
for (i = 2; i <= n; ++i) {
if (i == phi[i]) {
--phi[i];
for (j = 2 * i; j <= n; j += i) phi[j] = (phi[j] / i) * (i - 1);
}
}
for (i = n; i > 1; --i) solutie += 2LL * phi[i];
g << solutie;
}
