Cod sursa(job #590988)
Utilizator | Data | 21 mai 2011 14:59:51 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<fstream>
#define NrP 1000
using namespace std;
long phi[1000000];
long long s,n;
int i,j;
int main()
{
ifstream fin("fractii.in");
ofstream fout("fractii.out");
fin>>n;
for(i=2;i<=n;i++)
phi[i] = i-1;
for(i=2;i<=n;i++)
for(j=2*i;j<=n;j+=i)
phi[j] = phi[j] - phi[i];
for(i=2;i<=n;i++)
s+=phi[i];
fout<<2*s+1<<"\n";
return 0;
}