Cod sursa(job #957794)

Utilizator TwoOfDiamondsDaniel Alexandru Radu TwoOfDiamonds Data 6 iunie 2013 00:13:07
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>

using namespace std;

int main()
{
	ifstream IN("fractii.in");
	ofstream OUT("fractii.out");

	int n, nr[1000001];
	long long max = 0;

	IN >> n;

	//http://infoarena.ro/forum/index.php?topic=2512.0
	for (int i = 2; i <= n; i++)
		nr[i] = i - 1;

	for (int i = 2; i <=n; i++)
	{
		max += nr[i];
		for (int j = 2 * i; j <= n; j += i)
			nr[j] -= nr[i];
	}

	max = max * 2 + 1;

	OUT << max;

	return 0;



}