Cod sursa(job #3274335)
| Utilizator | Data | 6 februarie 2025 12:58:14 | |
|---|---|---|---|
| Problema | Fractii | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("fractii.in");
ofstream fout ("fractii.out");
const int nmax=1e6;
int n, phi[nmax];
void eratostene ()
{
phi[0]=phi[1]=1;
for (int i=2; i<=nmax; i++)
phi[i]=i-1;
for (int i=2; i<=nmax; i++)
{
for (int j=2*i; j<=nmax; j+=i)
phi[j]-=phi[i];
}
}
int main()
{
fin >> n;
eratostene();
int rez=0;
for (int i=1; i<=n; i++)
rez+=phi[i];
fout << rez*2-1;
return 0;
}
