Cod sursa(job #1717258)

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

using namespace std;

#define inf 100000
#define inf2 50000

long int n;
int totient[inf+1];

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

    //int totient[inf+1];

    f >> n;

    for (unsigned long int i = 1; i != inf; ++i)
        totient[i] = i-1;
    for (unsigned long int i = 2; i != inf2; ++i)
        for (unsigned long int j = 2*i; j <= inf; j += i)
            totient[j] -= totient[i];

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

    return 0;
}