Cod sursa(job #2232349)

Utilizator Alex03Runcan Alexandru Alex03 Data 18 august 2018 19:22:56
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("fractii.in"); ofstream fout ("fractii.out");

int n, i, j, np[1000005];
long long result = 1;

int main()
{
	fin >> n;
	for (i = 1; i <= n; i++)
		np[i] = i;
	for (i = 2; i <= n; i++)
	{
		if (np[i] == i)
			for (j = i; j <= n; j += i)
				np[j] = np[j] / i * (i - 1);
		result += (2LL * np[i]);
	}
	fout << result ;
}