Cod sursa(job #2254018)

Utilizator Moise_AndreiMoise Andrei Moise_Andrei Data 4 octombrie 2018 18:22:01
Problema Sum Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <bits/stdc++.h>
using namespace std;
ifstream in("sum.in");
ofstream out("sum.out");
int v[100005];
void ciur()
{
    for(int i = 1; i <= 100000; i ++)
        v[i] = i;
    for(int i = 2; i <= 100000; i ++)
    {
        if(v[i] == i)
        {
            for(int j = i; j <= 100000; j += i)
                v[j] = v[j] / i * (i - 1);
        }
    }

}
int main()
{
    int n;
    in >> n;
    ciur();
    for(int i = 1; i <= n; i ++)
    {
        int a;
        in >> a;
        out << 1LL * a * v[a] * 2;
    }
    return 0;
}