Cod sursa(job #2411722)

Utilizator Sergiu_01Sergiu Mihaila Sergiu_01 Data 21 aprilie 2019 10:45:32
Problema Fractii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.46 kb

#include <iostream>

#include <fstream>

#define nmax 1000005

using namespace std;



ifstream in("fractii.in");

ofstream out("fractii.out");



unsigned long long n, sol;

int v[nmax];



int main()

{

	in >> n;

	for (int i = 2; i <= n; v[i] = i - 1, ++i);

	for (int i = 2; i <= n / 2; ++i)

		for (int j = 2 * i; j <= n; v[j] -= v[i], j += i);

	for (int i = 2; i <= n; sol += v[i++]);

	out << 2 * sol + 1;

	return 0;

}