Pagini recente » Cod sursa (job #810191) | Junior challenge 2020, runda 2 | Cod sursa (job #1354329) | Cod sursa (job #89953) | Cod sursa (job #992854)
Cod sursa(job #992854)
#include<cstdio>
#include<algorithm>
using namespace std ;
#define maxn 100001
int phi[maxn] ;
int N ;
int main()
{
freopen("sum.in", "r", stdin);
freopen("sum.out", "w", stdout);
for(int i = 1; i <= maxn; ++i )
phi[i] = i - 1 ;
for(int i = 2; i <= maxn; ++i )
for(int j = 2 * i; j <= maxn; j += i )
phi[j] -= phi[i] ;
scanf("%d", &N);
while( N-- )
{
long long X ;
scanf("%lld", &X);
long long sol = X * phi[X] * 2 ;
printf("%lld\n", sol);
}
return 0 ;
}