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