Cod sursa(job #1099718)

Utilizator dr_personalityEftime Andrei Horatiu dr_personality Data 6 februarie 2014 10:52:40
Problema Sum Scor 85
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include<fstream>
using namespace std;
ifstream in("sum.in");
ofstream out("sum.out");

const int nmax = 100001;
long long v[nmax], n, x;

int main(){
	int player_unu=0;

	for(int i = 2; i<nmax; i++)
		v[i] = i;
	for(int i = 2; i<nmax; i++)
		if(v[i]==i)
			for(int j = i; j<nmax; j += i)
				v[j] = v[j]/i*(i-1);
	
	in>>n;
	for(int i = 0; i<n; i++)
	{
		in>>x;

		out<<2 * x * v[x]<<'\n';
	}

	return player_unu;
}