Cod sursa(job #328064)

Utilizator mathboyDragos-Alin Rotaru mathboy Data 30 iunie 2009 21:29:43
Problema Sum Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <cstdio> 
#define DIM 200003
#define MAX 2<<18
int u[MAX],j,t[MAX],i,m,k;
long long s;
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);
    s=t[k]*2*k;
    printf("%lld\n",s);
    }
return 0;
}