Pagini recente » Cod sursa (job #2002401) | Cod sursa (job #132920) | Cod sursa (job #2022094)
#include <iostream>
#include <fstream>
#define max 1000005
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
long long n, x, y, i, j, tot, d, rez, sum[max];
int nr[max];
bool eth[max];
int main () {
for (i = 2; i <= max; i++)
if (eth[i] == 0)
{
x = i;
for (j = 2; i * j <= max; j++)
{
eth[i*j] = 1; sum[i*j] += x; nr[i*j] += ((i*j)-i) / i;
x += i*j;
}
}
fin >> n;
for (i = 1; i <= n; i++)
{
fin >> y;
tot = (y*2) * (y*2-1) / 2;
d = 2 * sum[y] + nr[y] * y + y;
rez = tot - d;
fout << rez << "\n";
}
}