Cod sursa(job #2197096)

Utilizator vladth11Vlad Haivas vladth11 Data 21 aprilie 2018 10:07:59
Problema Sum Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <fstream>
#define N 100001
using namespace std;
ifstream cin("sum.in");
ofstream cout("sum.out");
int e[N];
void calc_Euler( int n ) {
  for ( int i = 2; i <= n; i ++ )
    e[i] = i;
  for ( int i = 2; i <= n; i ++ )
    if ( e[i] == i )
      for ( int j = i; j <= n; j += i )
        e[j] = e[j] / i * ( i - 1 );
}
int main()
{
    int n,x,i,y,sum = 0,j,w;
    cin >> n;
    calc_Euler(100001);
    for(i = 0; i < n; i++)
    {
        cin >> x;
        cout << x*2*e[x] << "\n";
    }
    return 0;
}