Cod sursa(job #762105)
| Utilizator | Data | 28 iunie 2012 18:17:08 | |
|---|---|---|---|
| Problema | Sum | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <cstdio>
#define NMAX 100025
#define Sum(x) (2*x*v[x])
using namespace std;
long long v[NMAX],N;
void construct()
{
int i,j;
for(i=1;i<=NMAX;v[i]=i-1,i++);
for(i=2;i<=NMAX;i++)
for(j=2*i;j<=NMAX;j+=i)
v[j]-=v[i];
}
int main()
{
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
int T;
construct();
scanf("%d",&T);
while(T--)
{
scanf("%lld",&N);
printf("%lld\n",Sum(N));
}
return 0;
}
