Cod sursa(job #2114089)
| Utilizator | Data | 25 ianuarie 2018 14:51:31 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | ichb_10 | Marime | 0.5 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
const int NMAX = 1e6;
int n;
int phi[NMAX + 2];
long long ans;
int main()
{
in >> n;
for(int i = 1; i <= n; i++)
phi[i] = i - 1;
for(int i = 1; i <= n; i++)
for(int j = 2 * i; j <= n; j += i)
phi[j] -= phi[i];
ans = 1;
for(int i = 1; i <= n; i++)
ans += 2LL * phi[i];
out << ans << '\n';
return 0;
}
