Cod sursa(job #469491)

Utilizator bogdandudumanDuduman Bogdan Vlad bogdanduduman Data 7 iulie 2010 21:41:15
Problema Fractii Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <iostream>
#include <fstream>
using namespace std;
long ciur_eratostene[2000001];

int main()
{
	long i,j,n,nr;
	nr=0;
	ifstream f;
	ofstream g;

	f.open("fractii.in");
	g.open("fractii.out");
	f>>n;
	for(i = 2 ; i<=n;i++)
		ciur_eratostene[i]= i-1;

	for(i = 2 ; i<=n ;i++)
		for(j = 2*i; j<=n; j +=i )	
			ciur_eratostene[j] -= ciur_eratostene[i];

	for(i = 2 ; i<=n ;i++)
		nr= nr + ciur_eratostene[i];
	
	g<<nr*2+1;
	f.close();
	g.close();
	return 0;
}