Pagini recente » Cod sursa (job #1791044) | Cod sursa (job #367699) | Cod sursa (job #2771556) | Cod sursa (job #1780343) | Cod sursa (job #1777824)
#include <bits/stdc++.h>
using namespace std;
//ifstream fin("sum.in");
ofstream fout("sum.out");
int N, testCount, X, solution;
int v[100010];
char c;
inline int get_nr()
{
int number = 0;
c = getc(stdin);
while(!isdigit(c))
{
c = getc(stdin);
}
while (isdigit(c))
{
number = number * 10 + c - '0';
c = getc(stdin);
}
return number;
}
int main()
{
freopen("sum.in", "r", stdin);
//fin >> testCount;
testCount = get_nr();
for(int i = 1; i <= 100000; i ++)
{
v[i] = i;
}
for(int i = 2; i <= 100000; i ++)
{
if(v[i] == i)
{
for(int j = i; j < 100000; j += i)
{
v[j] = v[j] / i * (i - 1);
}
}
}
while(testCount --)
{
//fin >> X;
//fscanf(stdin,"%d", &X);
X = get_nr();
unsigned long long solution = 1LL * X * v[X] * 2;
fout << solution << '\n';
}
return 0;
}