Mai intai trebuie sa te autentifici.
Cod sursa(job #2022095)
Utilizator | Data | 15 septembrie 2017 17:22:05 | |
---|---|---|---|
Problema | Sum | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <iostream>
#include <fstream>
#define max 100005
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";
}
}