Cod sursa(job #3005594)
Utilizator | Biclineru Radu Radu_Bicli | Data | 17 martie 2023 09:20:02 |
---|---|---|---|
Problema | Sum | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
int q, x;
int phi[100002];
static inline void setUp() {
for(int i = 1; i <= 100000; i++) phi[i] = i;
for(int i = 2; i <= 100000; i++) {
if(phi[i] == i) {
phi[i]--;
for(int j = 2 * i; j <= 100000; j += i) phi[j] = phi[j] / i * (i - 1);
}
}
}
int main() {
setUp();
fin >> q;
while(q--) {
fin >> x;
fout << 2LL * x * phi[x] << "\n";
}
return 0;
}