Cod sursa(job #2268041)

Utilizator razvanboabesrazvan boabes razvanboabes Data 24 octombrie 2018 14:27:23
Problema Sum Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <fstream>

using namespace std;
ifstream in("sum.in");
ofstream out("sum.out");
int v[100005];
void ciur( int n )
{
    for ( int i = 2; i <= n; i ++ )
        v[i] = i;
    for ( int i = 2; i <= n; i ++ )
        if ( v[i] == i )
            for ( int j = i; j <= n; j += i )
                v[j] = v[j] / i * ( i - 1 );
}
int main()
{
    long long x,i,n;
    in>> n;
    ciur (100000) ;
    for(i=1; i<= n; i++){
        in>>x;
        out<<v[x]*2*x<<'\n';
    }
    return 0;
}