Cod sursa(job #328055)

Utilizator mathboyDragos-Alin Rotaru mathboy Data 30 iunie 2009 21:17:07
Problema Sum Scor 65
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <cstdio> 
#define DIM 10000
int u[DIM+1],sum[DIM+1],j,t[DIM+1],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("%d\n",t[k]*2*k);
    }
return 0;
}