Cod sursa(job #1254639)

Utilizator costty94Duica Costinel costty94 Data 3 noiembrie 2014 09:03:04
Problema Sum Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <stdio.h>
#include <stdlib.h>

int v[100111];
int n, x, i, y, j;


void suma()
{
	for(y = 2; y <= 100001; y++)
		v[y] = y;
	for(y = 2; y <= 100001; y++)
	{
		if(v[y] == y)
		{
			for(j = y; j <= 100001; j += y)
				v[j] = v[j] / y * (y - 1);
		}
	}
}


int main()
{
	freopen("sum.in", "r", stdin);
	freopen("sum.out", "w", stdout);

	scanf("%d", &n);
	suma();
	for(i = 0; i < n; i++)
	{
		
		scanf("%d", &x);

		printf("%lld\n", (long long) 2 * x * v[x]);
	}
	return 0;
}