Pagini recente » Cod sursa (job #3040692) | Cod sursa (job #1284020) | Cod sursa (job #1271147) | Cod sursa (job #3193790) | Cod sursa (job #2779980)
#include <iostream>
#include <fstream>
using namespace std;
int e[100001];
void euler(int n){
for(int i = 2; i <= n; i++)
e[i]=i;
for(int i = 2; i <= n; i++){
if(e[i] == i){
for(int j = i; j <= n; j += i)
e[j] = e[j] / i * (i - 1);
}
}
}
int main()
{
ifstream fin("sum.in");
ofstream fout("sum.out");
int n;
fin >> n;
euler(100000);
for(int cnt = 0; cnt < n; cnt++){
int x;
fin >> x;
fout << e[x] * 2 * x << "\n";
}
return 0;
}