Cod sursa(job #328929)
Utilizator | Data | 3 iulie 2009 22:09:34 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <fstream.h>
#define MaxN 1000009
int i,j,n,v[MaxN];
long long nr;
int main()
{
ifstream fin("fractii.in");
fin>>n;
fin.close();
for(i=1;i<=n;i++)
v[i]=i-1;
for(i=2;i<=n;i++)
{
for(j=2*i;j<=n;j+=i)
v[j]-=v[i];
nr+=v[i];
}
nr*=2;
nr++;
ofstream fout("fractii.out");
fout<<nr;
fout.close();
return 0;
}