Cod sursa(job #1717007)

Utilizator SburlyAndrei Florin Sburly Data 14 iunie 2016 09:46:27
Problema Sum Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 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 (int i = 1; i < inf; ++i)
        totient[i] = i-1;
    for (int i = 2; i < inf; ++i)
        for (int j = 2*i; j <= inf; j += i)
            totient[j] -= totient[i];

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

    return 0;
}