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