Cod sursa(job #2592443)

Utilizator darkeagleDaniel Popescu darkeagle Data 1 aprilie 2020 18:17:07
Problema Sum Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <iostream>
#include <cstdio>
#define nmax 100005
using namespace std;

int  n;
int  phi[nmax];
int main() {
     freopen("sum.in", "rt", stdin);
	
freopen("sum.out", "wt", stdout);
     int  i, j, x;
     
        phi[1] = 0;  
     for ( i=1;i<=nmax;i++) phi[i]=i;

for ( i=2;i<=nmax;i++)
   if (phi[i]==i)
      for (j=i;j<=nmax;j+=i) phi[j] /=i, phi[j] *= (i-1);
        long long  t;
        scanf("%d", &n);
    for (i = 1;i <= n;i++) {
        scanf("%d",&x);
        t = (long long)x * phi[x] * 2;
        printf("%lld\n",t);
    }
     
  

    return 0;

}