Cod sursa(job #669095)
| Utilizator | Data | 26 ianuarie 2012 09:27:05 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
int n,phi[1000000];
long long total=0;
ifstream in("fractii.in");
in >> n;
in.close();
for (int i = 2; 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];
total+=phi[i];
}
ofstream out("fractii.out");
out << 2*total + 1;
out.close();
return 0;
}
