Cod sursa(job #2778398)

Utilizator Theodor17Pirnog Theodor Ioan Theodor17 Data 1 octombrie 2021 12:26:46
Problema Sum Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <fstream>
#define ll unsigned long long
#define limit 100000

using namespace std;

ifstream cin("sum.in");
ofstream cout("sum.out");

int n, x;
short indicator[1000001];


void ind_euler(){

    for(int i = 1; i <= limit; i++)
        indicator[i] = i;

    for(int i = 2; i <= limit; i++){

        if(indicator[i] == i){

            indicator[i]++; // il pun si pe 1

            for(int j = i; j <= limit; j += i)
                indicator[j] = indicator[j] / i * (i - 1);
        
        }

    }


}

int main(){

    cin >> n;
    ind_euler();

    for(int i = 1; i <= n; i++){

        cin >> x;
        cout << indicator[x] * 2 * x << "\n";

    }

}