Cod sursa(job #429395)
| Utilizator | Data | 30 martie 2010 08:54:26 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream>
#include <math.h>
#define nmax 1000005
using namespace std;
int n;
long long nrt, phi[nmax];
void citire ()
{
ifstream in("fractii.in");
in >> n;
}
void solve ()
{
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];
}
int main ()
{
citire ();
solve ();
nrt = 1;
for (int i = 2; i <= n; i++)
nrt += phi[i] *2;
ofstream out("fractii.out");
out << nrt;
}
