Cod sursa(job #120745)
| Utilizator | Data | 6 ianuarie 2008 14:51:07 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
/*Fractii*/
#include <fstream>
#define NMax 1000001
using namespace std;
int n;
long phi[NMax];
int main()
{
ifstream fin("fractii.in");
fin >> n;
fin.close();
for( int i=1; i<=n; i++ )
phi[i] = i-1;
for( int i=2; i<=n; i++ )
for( int j=2*i; j<=n; j+=i )
phi[j]-=phi[i];
long long s=1;
for( int i=2; i<=n; i++ )
s+=2*phi[i];
ofstream fout("fractii.out");
fout << s;
fout.close();
return 0;
}
