Cod sursa(job #1717003)

Utilizator SburlyAndrei Florin Sburly Data 14 iunie 2016 09:39:49
Problema Sum Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
/********************
    Created by Sburly
********************/
#include <fstream>

using namespace std;

#define inf 100001

long int n;
int totient[inf];

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

    f >> n;

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

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

    return 0;
}