Cod sursa(job #1717002)

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

using namespace std;

long int n;
long int i,j;
long int inf =   100005;
long int totient[100005];

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

    f >> n;

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

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

    return 0;
}