Cod sursa(job #2463238)
Utilizator | Data | 28 septembrie 2019 11:11:30 | |
---|---|---|---|
Problema | Fractii | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
const int N = 1e6+5;
int phi[N];
int main()
{
int n,s=0;
in >> n;
for (int i = 1; i<=n; i++)
phi[i] = i;
for (int i = 1; i<=n; i++)
{
for (int j = 2*i; j<=n; j+=i)
phi[j]-=phi[i];
s+=phi[i];
}
out << 2*s-1;
}