Cod sursa(job #2588765)
Utilizator | Cobaschi Aser aser.cobaschi | Data | 25 martie 2020 13:50:33 |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
const int N=1000001;
int n,theta[N];
long long sol;
int main()
{
f>>n;
for(int i=1;i<=n;i++)
theta[i]=i;
theta[1]=0;
for(int i=2;i<=n;i++)
if(theta[i]==i)
{
for(int j=i;j<=n;j+=i)
{
theta[j]/=i;
theta[j]*=i-1;
}
}
for(int i=2;i<=n;i++)
sol+=2*theta[i];
g<<1+sol;
return 0;
}