Cod sursa(job #328066)

Utilizator mathboyDragos-Alin Rotaru mathboy Data 30 iunie 2009 21:35:11
Problema Sum Scor 85
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <cstdio> 
#define DIM 200005
#define MAX 200010
int u[MAX],j,t[MAX],i,m,k;
using namespace std;
int tot()
{
for(i=2; i<=DIM; ++i) t[i]=i;
for(i=2; i<=DIM; ++i) 
   {
    if(u[i]==0)
      {
       for(j=i;j<=DIM;j+=i)
          {
           u[j]=1;
           t[j]=t[j]-t[j]/i;
          }
       }
   }
   
}    
int main()
{
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
scanf("%d\n",&m);
tot();
    while(m--)
    {
    scanf("%d\n",&k);
    printf("%lld\n",(long long)t[k]*2*k);
    }
return 0;
}