Cod sursa(job #810159)

Utilizator stoicatheoFlirk Navok stoicatheo Data 9 noiembrie 2012 19:25:59
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.37 kb
#include <fstream>
using namespace std;
int n,s[1000001];
unsigned long long sum;
ifstream f("fractii.in"); ofstream g("fractii.out");
int main()
{  
	f>>n;
	for(int i=2; i <= n; ++i) s[i]=i-1;
	for(int i=2; i<=n; ++i)
		{   
			sum +=s[i];
			for(int j=i+i; j<=n; j += i) 
				s[j]-=s[i];
	}
			g<<sum * 2 + 1<<'\n';
			g.close();
			return 0;
		}