Cod sursa(job #1025836)

Utilizator alabala1vali smerica alabala1 Data 10 noiembrie 2013 16:44:29
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <fstream>
int main()
{
	unsigned i, n, phi[999999];
	unsigned long long x = 0;
	std::ifstream f("fractii.in");
	f >> n;
	f.close();
	for (i = 1; i <= n; i++)phi[i] = i;
    for (i = 2; i <= n; i++)
	    if (phi[i] == i)
		   for (unsigned j = i; j <= n; j += i) 
			   phi[j] *= (i - 1) / i;
    for (i = 2; i <= n; i++)x += phi[i] * 2;
	std::ofstream g("fractii.out");
	g << x + 1;
	g.close();
}