Cod sursa(job #2392594)
Utilizator | Data | 30 martie 2019 10:56:13 | |
---|---|---|---|
Problema | Sum | Scor | 45 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
// indicatorul euler
#include <bits/stdc++.h>
#define Nmax 100000
using namespace std;
ifstream f("sum.in");
ofstream g("sum.out");
int phi[100002], i, j, t, x;
int main()
{
for(i = 2; i <= Nmax; i ++)
phi[i] = i - 1;
for(i = 2; i * i <= Nmax; i ++)
for(j = i * 2; j <= Nmax; j = j + i)
phi[j] = phi[j] - phi[i];
f >> t;
while(t --)
{
f >> x;
g << 1LL * 2 * x * phi[x] << "\n";
}
f.close();
g.close();
return 0;
}