Cod sursa(job #986157)

Utilizator enedumitruene dumitru enedumitru Data 17 august 2013 21:35:12
Problema Sum Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.37 kb
#include<cstdio>
#define N 100001
using namespace std;
int phi[N+1];
int main()
{	int n,i,j; long long x;
	for(i=1;i<=N;i++)phi[i]=i-1;
    for(i=2;i<=N;i++)
        for(j=2*i;j<=N;j+=i) phi[j]-=phi[i];
	freopen("sum.in","r",stdin);
	freopen ("sum.out","w",stdout);
    scanf("%ld",&n);
    while(n--)
		scanf("%lld",&x), printf("%lld\n",x*phi[x]*2);
    return 0;
}