Cod sursa(job #1997181)
Utilizator | Data | 3 iulie 2017 16:26:55 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int main()
{
int n,i,j;
fin>>n;
long long int ct=0;
int phi[n+1];
for (i=1; i<=n; i++)
{
phi[i]=i;
}
for (i=2; i<=n; i++)
{
if (phi[i]==i)
{
for (j=i; j<=n; j+=i)
{
phi[j]/=i;
phi[j]*=(i-1);
}
}
}
for (i=1; i<=n; i++)
{
ct+=phi[i];
}
fout<<2*ct-1;
}