Cod sursa(job #1025791)
Utilizator | Data | 10 noiembrie 2013 16:03:42 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include <fstream>
int main()
{
unsigned i, n, phi[999999];
unsigned long x = 0;
std::ifstream f("fractii.in");
f >> n;
f.close();
for (i = 2; i <= n; phi[i++] = i - 1);
for (i = 2; i <= n; i++)
for (unsigned j = 2 * i; j <= n; phi[j ] -= phi[i],j+=i);
for (i = 2; i <= n; i++) x += phi[i] * 2;
std::ofstream g("fractii.out");
g << x + 1;
g.close();
}