Cod sursa(job #1463873)
| Utilizator | Data | 21 iulie 2015 18:01:09 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <fstream>
#include <math.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
long phi[1000000];
int main()
{
long n,i,j;
fin>>n;
long long s=0;
for (i = 1; i <= n; ++i)
phi[i] = i-1;
for (i = 2; i <= n; ++i)
for (j = 2*i; j <= n; j += i)
phi[j] -= phi[i];
for(i=1;i<=n;i++)
s+=phi[i];
fout<<2*s+1<<"\n";
return 0;
}
