Cod sursa(job #2429840)
Utilizator | andrei42O andrei42O | Data | 11 iunie 2019 13:39:20 |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
ifstream f("fractii.in");
ofstream g("fractii.out");
int n, phi[N];
int64_t sol = 1;
int main()
{
f >> n;
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] = phi[j] / i * (i - 1);
sol += 2 * phi[i];
}
g << sol;
return 0;
}