Cod sursa(job #2259873)
Utilizator | Danciu Ana Cezara cezarada | Data | 13 octombrie 2018 21:11:48 |
---|---|---|---|
Problema | Sum | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <fstream>
using namespace std;
ifstream in("sum.in");
ofstream out("sum.out");
long long const VM = 1000003;
long long e[1000003];
void Euler()
{
for (int i = 2; i < VM; i++)
e[i] = i;
for (int i = 2; i < VM; i++)
{
if (e[i] == i)
{
for (int j = i; j < VM; j += i)
{
e[j]= e[j] / i * (i - 1);
}
}
}
}
int main()
{
int n, x;
in >> n;
for (int i = 1; i <= n; i++)
{
in >> x;
Euler();
out << 2 * x * e[x] << '\n';
}
return 0;
}