Cod sursa(job #2215393)
| Utilizator | Data | 21 iunie 2018 22:07:31 | |
|---|---|---|---|
| Problema | A+B | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
long long sum;
int n, phi[1000002];
void DaiCuPhi () {
for (int i = 1; i <= n; i++)
phi[i] = i;
for (int i = 2; i <= n; i++)
if (phi[i] == i) {
for (int j = i; j <= n; j += i) {phi[j] /= i; phi[j] *= (i - 1);}
}
}
int main()
{
fin >> n;
DaiCuPhi();
for (int i = 1; i <= n; i++)
sum += phi[i];
fout << 2 * sum - 1;
return 0;
}
