Cod sursa(job #305304)
| Utilizator | Data | 16 aprilie 2009 21:47:07 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#define NMAX 1024000
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int a[NMAX], n;
long long int sol;
int main()
{
fin >> n;
sol = 0;
for (int i = 1; i <= n ; ++i) a[i] = i;
for (int i = 2; i <= n; ++i)
if (a[i] == i)
for (int j = i; j <= n; j += i) a[j] = a[j] /i * (i - 1);
for (int i = 1; i<= n; ++i) sol += a[i];
sol = 2 * sol -1;
fout << sol;
fin.close();
fout.close();
return 0;
}
