Cod sursa(job #1717992)

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

using namespace std;

int totient[100001];

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<100001;++i)
        totient[i]=i;
    for (i=2;i<100001;++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;
}