Cod sursa(job #328062)
Utilizator | Data | 30 iunie 2009 21:26:12 | |
---|---|---|---|
Problema | Sum | Scor | 85 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <cstdio>
#define DIM 200003
#define MAX 300000
long long u[MAX],sum[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("%lld\n",&m);
tot();
while(m--)
{
scanf("%lld\n",&k);
printf("%lld\n",t[k]*2*k);
}
return 0;
}