Cod sursa(job #475702)

Utilizator unknownliviuMaria Liviu Valentin unknownliviu Data 8 august 2010 01:53:10
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include<fstream>
using namespace std;
int *t = new int [1000001];
int main()
{
	ifstream in("fractii.in");
	ofstream out("fractii.out");
	int n,i;
	in>>n;
	unsigned long long tot=0;
	for( i=2;i<=n;i++)
		t[i]=i;
	for( i=2;i<=n;i++)
		if(t[i]==i)
			for(int j=i;j<=n;j+=i)
				t[j]-=t[j]/i;
	for( i=2;i<=n;i++)
		tot+=t[i];
	tot*=2;
	tot++;
	out<<tot;
	return 0;
}