Cod sursa(job #2781216)

Utilizator Theodor17Pirnog Theodor Ioan Theodor17 Data 8 octombrie 2021 19:07:30
Problema Sum Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <fstream>
#define ll unsigned long long

using namespace std;

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

const int N = 1e5;
int n, x;
int phi[N + 1];

void ciur(){

    for(int i = 1; i <= N; i++)
        phi[i] = i;

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

        if(phi[i] == i){

            for(int j = i; j <= N; j += i)
                phi[j] = phi[j] / i * (i - 1);

        }

    }

}

int main(){

    cin >> n;
    ciur();
    while(n){

        cin >> x;
        cout << (2LL * phi[x] * x) << "\n"; 

        n--;    
    }

}