Cod sursa(job #1717275)

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

using namespace std;

#define inf 100001
#define inf2 50001

long int n;
int totient[inf];

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

    f >> n;

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

    for(unsigned long int i = n; i--;)
    {
        int x;
        f >> x;
        g << (((unsigned long long int)x*totient[x])<<1) << '\n';
    }
    return 0;
}