Cod sursa(job #1717283)

Utilizator SburlyAndrei Florin Sburly Data 14 iunie 2016 17:40:11
Problema Sum Scor 95
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
/********************
    Created by Sburly
********************/
#include <fstream>

using namespace std;

int totient[100001];

int main()
{
    ifstream f("sum.in");
    ofstream g("sum.out");

    long int n;
    f >> 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++)
    {
        int x;
        f >> x;
        g << (((unsigned long long int)x*totient[x])<<1) << '\n';
    }
    return 0;
}