Cod sursa(job #1717993)

Utilizator SburlyAndrei Florin Sburly Data 16 iunie 2016 12:10:32
Problema Sum Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
/********************
    Created by Sburly
********************/
#include <cstdio>

using namespace std;

#define inf 100001

int totient[inf];

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

    long int n;
    scanf("%lu", &n);

    int i,j;
    for (i=1;i!=inf;++i)
        totient[i]=i;
    for (i=2;i!=inf;++i)
        if (totient[i]==i)
            for (j=i;j<100001;j+=i)
                totient[j] /=i, totient[j] *= (i-1);

    for(i = 0; i!=n;++i)
    {
        unsigned long long int x;
        scanf("%llu", &x);
        printf("%llu\n", (((unsigned long long int)x*totient[x])<<1));
    }
    return 0;
}